├── .editorconfig ├── .gitignore ├── README.md ├── lib ├── env.js ├── index.js └── run.js └── package.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | # Unix-style newlines with a newline ending every file 5 | [*.{js,css}] 6 | end_of_line = lf 7 | insert_final_newline = true 8 | indent_style = space 9 | indent_size = 2 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | /.yarn/* 6 | !/.yarn/patches 7 | !/.yarn/plugins 8 | !/.yarn/releases 9 | !/.yarn/sdks 10 | !/.yarn/versions 11 | 12 | # Swap the comments on the following lines if you don't wish to use zero-installs 13 | # Documentation here: https://yarnpkg.com/features/zero-installs 14 | #!/.yarn/cache 15 | /.pnp.* 16 | 17 | 18 | # testing 19 | /coverage 20 | 21 | # production 22 | build 23 | pkg 24 | dist 25 | 26 | # misc 27 | .DS_Store 28 | .env.local 29 | .env.development.local 30 | .env.test.local 31 | .env.production.local 32 | 33 | npm-debug.log* 34 | yarn-debug.log* 35 | yarn-error.log* 36 | 37 | *.log 38 | *.aes 39 | cypress/screenshots 40 | cypress/videos 41 | cypress/logs 42 | cypress/fixtures/profile.json 43 | cypress/fixtures/users.json 44 | .history 45 | 46 | yarn.lock -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tyarn 2 | 3 | yarn using npmmirror.com as registry 4 | 5 | 6 | ## usage 7 | 8 | ``` 9 | npm install yarn tyarn -g 10 | ``` 11 | 12 | ### install 13 | 14 | same with `yarn`, replace `yarn` with `tyarn`, for example: 15 | 16 | ``` 17 | tyarn add antd 18 | ``` 19 | 20 | ### publish 21 | 22 | use npm to publish 23 | -------------------------------------------------------------------------------- /lib/env.js: -------------------------------------------------------------------------------- 1 | const config = require('binary-mirror-config'); 2 | 3 | module.exports = config.china.ENVS; 4 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | 'use strict'; 4 | 5 | const env = require('./env'); 6 | 7 | const registry = 'https://registry.npmmirror.com'; 8 | // can not put inside run, ENOENT 9 | require('./run')(env, registry); 10 | 11 | -------------------------------------------------------------------------------- /lib/run.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const spawn = require('cross-spawn'); 4 | const path = require('path'); 5 | 6 | const v = (require('child_process').execSync('yarn -v', { 7 | encoding: 'utf-8' 8 | })); 9 | 10 | const cwd = process.cwd(); 11 | 12 | const v1 = v.startsWith('1.'); 13 | 14 | const yaml = require('js-yaml'); 15 | const fs = require('fs'); 16 | 17 | module.exports = function (env, registry) { 18 | const processEnv = process.env; 19 | let { yarn_npm_Registry_Server } = processEnv; 20 | const ymlPath = path.join(cwd, '.yarnrc.yml'); 21 | if (!v1 && !yarn_npm_Registry_Server && fs.existsSync(ymlPath)) { 22 | const doc = yaml.load(fs.readFileSync(ymlPath, 'utf8')) || {}; 23 | yarn_npm_Registry_Server = doc.npmRegistryServer; 24 | } 25 | if (registry) { 26 | if (v1) { 27 | env.yarn_registry = registry; 28 | } else { 29 | env.yarn_npm_Registry_Server = yarn_npm_Registry_Server || registry; 30 | } 31 | } 32 | if (!v1) { 33 | console.log('npmRegistryServer:', env.yarn_npm_Registry_Server); 34 | } 35 | spawn('yarn', process.argv.slice(2), { 36 | env: { 37 | ...processEnv, 38 | ...env, 39 | }, 40 | cwd: process.cwd(), 41 | stdio: 'inherit', 42 | }).on('exit', function (code) { 43 | process.exit(code); 44 | }); 45 | }; 46 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tyarn", 3 | "version": "0.3.8", 4 | "description": "yarn using npmmirror.com as registry", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1" 7 | }, 8 | "files": ["lib"], 9 | "bin": "lib/index.js", 10 | "repository": { 11 | "type": "git", 12 | "url": "git@github.com:yiminghe/tyarn.git" 13 | }, 14 | "keywords": [ 15 | "yarn", 16 | "taobao" 17 | ], 18 | "author": "yiminghe@gmail.com", 19 | "license": "MIT", 20 | "packageManager": "yarn@3.2.2", 21 | "dependencies": { 22 | "binary-mirror-config": "^1.34.0", 23 | "cross-spawn": "^4.0.2", 24 | "js-yaml": "^4.1.0" 25 | } 26 | } 27 | --------------------------------------------------------------------------------