@tramvai/cli 2.59.2 → 2.59.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli/bin-init.js +2 -0
- package/lib/cli/bin-init.js.map +1 -1
- package/lib/utils/commands/dependencies/packageHasVersion.js +12 -0
- package/lib/utils/commands/dependencies/packageHasVersion.js.map +1 -1
- package/lib/utils/fixYarnSettingsOverride.d.ts +1 -0
- package/lib/utils/fixYarnSettingsOverride.js +36 -0
- package/lib/utils/fixYarnSettingsOverride.js.map +1 -0
- package/package.json +3 -2
- package/src/cli/bin-init.ts +2 -0
- package/src/utils/commands/dependencies/packageHasVersion.ts +15 -0
- package/src/utils/fixYarnSettingsOverride.ts +34 -0
package/lib/cli/bin-init.js
CHANGED
|
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const resolve_1 = tslib_1.__importDefault(require("resolve"));
|
|
5
5
|
const clearExecArgv_1 = require("../utils/clearExecArgv");
|
|
6
|
+
const fixYarnSettingsOverride_1 = require("../utils/fixYarnSettingsOverride");
|
|
6
7
|
const handleErrors_1 = require("../utils/handleErrors");
|
|
7
8
|
const sentry_1 = require("../utils/sentry");
|
|
8
9
|
(0, clearExecArgv_1.clearExecArgv)();
|
|
9
10
|
(0, sentry_1.initSentry)();
|
|
10
11
|
(0, handleErrors_1.handleErrors)();
|
|
12
|
+
(0, fixYarnSettingsOverride_1.fixYarnSettingsOverride)();
|
|
11
13
|
(0, resolve_1.default)('@tramvai/cli/lib/cli', {
|
|
12
14
|
basedir: process.cwd(),
|
|
13
15
|
}, (error, projectLocalCli) => {
|
package/lib/cli/bin-init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin-init.js","sourceRoot":"","sources":["../../src/cli/bin-init.ts"],"names":[],"mappings":";;;AAAA,8DAA8B;AAC9B,0DAAuD;AACvD,wDAAqD;AACrD,4CAA6C;AAE7C,IAAA,6BAAa,GAAE,CAAC;AAChB,IAAA,mBAAU,GAAE,CAAC;AACb,IAAA,2BAAY,GAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"bin-init.js","sourceRoot":"","sources":["../../src/cli/bin-init.ts"],"names":[],"mappings":";;;AAAA,8DAA8B;AAC9B,0DAAuD;AACvD,8EAA2E;AAC3E,wDAAqD;AACrD,4CAA6C;AAE7C,IAAA,6BAAa,GAAE,CAAC;AAChB,IAAA,mBAAU,GAAE,CAAC;AACb,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,iDAAuB,GAAE,CAAC;AAE1B,IAAA,iBAAO,EACL,sBAAsB,EACtB;IACE,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE;CACvB,EACD,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE;IACzB,2DAA2D;IAC3D,IAAI,KAAK,EAAE;QACT,OAAO,CAAC,aAAa,CAAC,CAAC;KACxB;SAAM;QACL,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;KAC9C;AACH,CAAC,CACF,CAAC"}
|
|
@@ -4,14 +4,26 @@ exports.packageHasVersion = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const util_1 = tslib_1.__importDefault(require("util"));
|
|
6
6
|
const child_process_1 = tslib_1.__importDefault(require("child_process"));
|
|
7
|
+
const ora_1 = tslib_1.__importDefault(require("ora"));
|
|
7
8
|
const exec = util_1.default.promisify(child_process_1.default.exec);
|
|
9
|
+
const addPaddingToString = (text) => text
|
|
10
|
+
.split('\n')
|
|
11
|
+
.map((line) => ` ${line}`)
|
|
12
|
+
.join('\n');
|
|
8
13
|
const packageHasVersion = (packageName, version) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
const spinner = (0, ora_1.default)(`Checking is ${packageName} package has ${version} version`).start();
|
|
9
15
|
try {
|
|
10
16
|
const { stdout } = yield exec(`npm view ${packageName}@${version} version`);
|
|
11
17
|
const hasVersion = !!stdout.trim().replace('\n', '');
|
|
18
|
+
spinner.stop();
|
|
12
19
|
return hasVersion;
|
|
13
20
|
}
|
|
14
21
|
catch (e) {
|
|
22
|
+
spinner.stop();
|
|
23
|
+
// TODO: replace with logger from di
|
|
24
|
+
console.log(`Checking failed with error:\n`);
|
|
25
|
+
console.log(`${addPaddingToString(e.message)}`);
|
|
26
|
+
console.log(`${addPaddingToString(e.stack.replace(e.message, ''))}\n`);
|
|
15
27
|
return false;
|
|
16
28
|
}
|
|
17
29
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageHasVersion.js","sourceRoot":"","sources":["../../../../src/utils/commands/dependencies/packageHasVersion.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AACxB,0EAAyC;
|
|
1
|
+
{"version":3,"file":"packageHasVersion.js","sourceRoot":"","sources":["../../../../src/utils/commands/dependencies/packageHasVersion.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AACxB,0EAAyC;AACzC,sDAAsB;AAEtB,MAAM,IAAI,GAAG,cAAI,CAAC,SAAS,CAAC,uBAAY,CAAC,IAAI,CAAC,CAAC;AAE/C,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,EAAE,CAC1C,IAAI;KACD,KAAK,CAAC,IAAI,CAAC;KACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;KAC1B,IAAI,CAAC,IAAI,CAAC,CAAC;AAET,MAAM,iBAAiB,GAAG,CAAO,WAAmB,EAAE,OAAe,EAAoB,EAAE;IAChG,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC,eAAe,WAAW,gBAAgB,OAAO,UAAU,CAAC,CAAC,KAAK,EAAE,CAAC;IAEzF,IAAI;QACF,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,YAAY,WAAW,IAAI,OAAO,UAAU,CAAC,CAAC;QAC5E,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACrD,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,OAAO,UAAU,CAAC;KACnB;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,oCAAoC;QACpC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;QAC7C,OAAO,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAChD,OAAO,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QACvE,OAAO,KAAK,CAAC;KACd;AACH,CAAC,CAAA,CAAC;AAhBW,QAAA,iBAAiB,qBAgB5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function fixYarnSettingsOverride(): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fixYarnSettingsOverride = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const ini_1 = tslib_1.__importDefault(require("ini"));
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
8
|
+
function readNpmRc(cwd) {
|
|
9
|
+
const npmrcPath = path_1.default.join(cwd, '.npmrc');
|
|
10
|
+
return fs_1.default.existsSync(npmrcPath) ? fs_1.default.readFileSync(npmrcPath).toString('utf8') : '';
|
|
11
|
+
}
|
|
12
|
+
function fixYarnSettingsOverride() {
|
|
13
|
+
const cwd = process.cwd();
|
|
14
|
+
const npmRc = readNpmRc(cwd);
|
|
15
|
+
const classicYarn = process.env.npm_config_user_agent
|
|
16
|
+
? process.env.npm_config_user_agent.indexOf('yarn/1') !== -1
|
|
17
|
+
: false;
|
|
18
|
+
// yarn 1 overrides npmrc settings with its own set of npm config envs so `yarn publish-command` wont work if it depends on those
|
|
19
|
+
// strict-ssl is one of those important settings, so copy it to envs and override yarn default one
|
|
20
|
+
if (classicYarn && npmRc) {
|
|
21
|
+
if (npmRc.indexOf('strict-ssl') !== -1) {
|
|
22
|
+
const parsedNpmRc = ini_1.default.parse(npmRc);
|
|
23
|
+
if (parsedNpmRc['strict-ssl'] !== undefined) {
|
|
24
|
+
process.env.npm_config_strict_ssl = parsedNpmRc['strict-ssl'];
|
|
25
|
+
}
|
|
26
|
+
if (parsedNpmRc.registry !== undefined) {
|
|
27
|
+
process.env.npm_config_registry = parsedNpmRc.registry;
|
|
28
|
+
}
|
|
29
|
+
if (parsedNpmRc.ca !== undefined) {
|
|
30
|
+
process.env.npm_config_ca = parsedNpmRc.ca;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.fixYarnSettingsOverride = fixYarnSettingsOverride;
|
|
36
|
+
//# sourceMappingURL=fixYarnSettingsOverride.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixYarnSettingsOverride.js","sourceRoot":"","sources":["../../src/utils/fixYarnSettingsOverride.ts"],"names":[],"mappings":";;;;AAAA,sDAAsB;AACtB,wDAAwB;AACxB,oDAAoB;AAEpB,SAAS,SAAS,CAAC,GAAW;IAC5B,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC3C,OAAO,YAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,YAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACrF,CAAC;AAED,SAAgB,uBAAuB;IACrC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7B,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB;QACnD,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC5D,CAAC,CAAC,KAAK,CAAC;IAEV,iIAAiI;IACjI,kGAAkG;IAClG,IAAI,WAAW,IAAI,KAAK,EAAE;QACxB,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE;YACtC,MAAM,WAAW,GAAG,aAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAErC,IAAI,WAAW,CAAC,YAAY,CAAC,KAAK,SAAS,EAAE;gBAC3C,OAAO,CAAC,GAAG,CAAC,qBAAqB,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC;aAC/D;YACD,IAAI,WAAW,CAAC,QAAQ,KAAK,SAAS,EAAE;gBACtC,OAAO,CAAC,GAAG,CAAC,mBAAmB,GAAG,WAAW,CAAC,QAAQ,CAAC;aACxD;YACD,IAAI,WAAW,CAAC,EAAE,KAAK,SAAS,EAAE;gBAChC,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,WAAW,CAAC,EAAE,CAAC;aAC5C;SACF;KACF;AACH,CAAC;AAxBD,0DAwBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/cli",
|
|
3
|
-
"version": "2.59.
|
|
3
|
+
"version": "2.59.3",
|
|
4
4
|
"description": "Cli инструмент для сборки и запуска приложений",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@tinkoff/request-plugin-protocol-http": "^0.11.6",
|
|
69
69
|
"@tinkoff/utils": "^2.1.3",
|
|
70
70
|
"@tramvai/build": "3.0.7",
|
|
71
|
-
"@tramvai/react": "2.59.
|
|
71
|
+
"@tramvai/react": "2.59.3",
|
|
72
72
|
"@tramvai/tools-check-versions": "0.4.7",
|
|
73
73
|
"@tramvai/tools-migrate": "0.6.8",
|
|
74
74
|
"ajv": "^6.12.6",
|
|
@@ -106,6 +106,7 @@
|
|
|
106
106
|
"handlebars": "^4.7.7",
|
|
107
107
|
"http-proxy": "^1.18.1",
|
|
108
108
|
"image-size": "^1.0.2",
|
|
109
|
+
"ini": "^3.0.1",
|
|
109
110
|
"inquirer": "^7.3.3",
|
|
110
111
|
"inquirer-autocomplete-prompt": "^1.4.0",
|
|
111
112
|
"inspectpack": "^4.7.1",
|
package/src/cli/bin-init.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import resolve from 'resolve';
|
|
2
2
|
import { clearExecArgv } from '../utils/clearExecArgv';
|
|
3
|
+
import { fixYarnSettingsOverride } from '../utils/fixYarnSettingsOverride';
|
|
3
4
|
import { handleErrors } from '../utils/handleErrors';
|
|
4
5
|
import { initSentry } from '../utils/sentry';
|
|
5
6
|
|
|
6
7
|
clearExecArgv();
|
|
7
8
|
initSentry();
|
|
8
9
|
handleErrors();
|
|
10
|
+
fixYarnSettingsOverride();
|
|
9
11
|
|
|
10
12
|
resolve(
|
|
11
13
|
'@tramvai/cli/lib/cli',
|
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
import util from 'util';
|
|
2
2
|
import childProcess from 'child_process';
|
|
3
|
+
import ora from 'ora';
|
|
3
4
|
|
|
4
5
|
const exec = util.promisify(childProcess.exec);
|
|
5
6
|
|
|
7
|
+
const addPaddingToString = (text: string) =>
|
|
8
|
+
text
|
|
9
|
+
.split('\n')
|
|
10
|
+
.map((line) => ` ${line}`)
|
|
11
|
+
.join('\n');
|
|
12
|
+
|
|
6
13
|
export const packageHasVersion = async (packageName: string, version: string): Promise<boolean> => {
|
|
14
|
+
const spinner = ora(`Checking is ${packageName} package has ${version} version`).start();
|
|
15
|
+
|
|
7
16
|
try {
|
|
8
17
|
const { stdout } = await exec(`npm view ${packageName}@${version} version`);
|
|
9
18
|
const hasVersion = !!stdout.trim().replace('\n', '');
|
|
19
|
+
spinner.stop();
|
|
10
20
|
return hasVersion;
|
|
11
21
|
} catch (e) {
|
|
22
|
+
spinner.stop();
|
|
23
|
+
// TODO: replace with logger from di
|
|
24
|
+
console.log(`Checking failed with error:\n`);
|
|
25
|
+
console.log(`${addPaddingToString(e.message)}`);
|
|
26
|
+
console.log(`${addPaddingToString(e.stack.replace(e.message, ''))}\n`);
|
|
12
27
|
return false;
|
|
13
28
|
}
|
|
14
29
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import ini from 'ini';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
|
|
5
|
+
function readNpmRc(cwd: string): string {
|
|
6
|
+
const npmrcPath = path.join(cwd, '.npmrc');
|
|
7
|
+
return fs.existsSync(npmrcPath) ? fs.readFileSync(npmrcPath).toString('utf8') : '';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function fixYarnSettingsOverride() {
|
|
11
|
+
const cwd = process.cwd();
|
|
12
|
+
const npmRc = readNpmRc(cwd);
|
|
13
|
+
const classicYarn = process.env.npm_config_user_agent
|
|
14
|
+
? process.env.npm_config_user_agent.indexOf('yarn/1') !== -1
|
|
15
|
+
: false;
|
|
16
|
+
|
|
17
|
+
// yarn 1 overrides npmrc settings with its own set of npm config envs so `yarn publish-command` wont work if it depends on those
|
|
18
|
+
// strict-ssl is one of those important settings, so copy it to envs and override yarn default one
|
|
19
|
+
if (classicYarn && npmRc) {
|
|
20
|
+
if (npmRc.indexOf('strict-ssl') !== -1) {
|
|
21
|
+
const parsedNpmRc = ini.parse(npmRc);
|
|
22
|
+
|
|
23
|
+
if (parsedNpmRc['strict-ssl'] !== undefined) {
|
|
24
|
+
process.env.npm_config_strict_ssl = parsedNpmRc['strict-ssl'];
|
|
25
|
+
}
|
|
26
|
+
if (parsedNpmRc.registry !== undefined) {
|
|
27
|
+
process.env.npm_config_registry = parsedNpmRc.registry;
|
|
28
|
+
}
|
|
29
|
+
if (parsedNpmRc.ca !== undefined) {
|
|
30
|
+
process.env.npm_config_ca = parsedNpmRc.ca;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|