@tramvai/cli 2.73.0 → 2.74.0
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/bin/platform-debug.js +4 -8
- package/lib/cli/bin-init.js +0 -4
- package/lib/cli/bin-init.js.map +1 -1
- package/lib/cli/runCLI.js +5 -1
- package/lib/cli/runCLI.js.map +1 -1
- package/lib/commands/add/add.js +16 -4
- package/lib/commands/add/add.js.map +1 -1
- package/lib/commands/add/checkPackageValidator.js +2 -4
- package/lib/commands/add/checkPackageValidator.js.map +1 -1
- package/lib/commands/static/application.js +8 -0
- package/lib/commands/static/application.js.map +1 -1
- package/lib/commands/update/dependantLibs.js +6 -6
- package/lib/commands/update/dependantLibs.js.map +1 -1
- package/lib/commands/update/update.js +29 -7
- package/lib/commands/update/update.js.map +1 -1
- package/lib/commands/update/updatePackageJson.js +37 -31
- package/lib/commands/update/updatePackageJson.js.map +1 -1
- package/lib/library/babel/index.js +3 -1
- package/lib/library/babel/index.js.map +1 -1
- package/lib/models/command.js +1 -1
- package/lib/models/command.js.map +1 -1
- package/lib/models/logger.d.ts +1 -0
- package/lib/models/logger.js +4 -4
- package/lib/models/logger.js.map +1 -1
- package/lib/models/task.js +1 -1
- package/lib/models/task.js.map +1 -1
- package/lib/utils/commands/dependencies/getLatestPackageVersion.d.ts +1 -1
- package/lib/utils/commands/dependencies/getLatestPackageVersion.js +11 -3
- package/lib/utils/commands/dependencies/getLatestPackageVersion.js.map +1 -1
- package/lib/utils/commands/dependencies/packageHasVersion.js +3 -18
- package/lib/utils/commands/dependencies/packageHasVersion.js.map +1 -1
- package/package.json +7 -4
- package/src/cli/bin-init.ts +0 -4
- package/src/cli/runCLI.ts +7 -1
- package/src/commands/add/add.ts +17 -4
- package/src/commands/add/checkPackageValidator.ts +2 -5
- package/src/commands/static/application.ts +9 -0
- package/src/commands/update/dependantLibs.ts +5 -5
- package/src/commands/update/update.ts +34 -8
- package/src/commands/update/updatePackageJson.spec.ts +14 -20
- package/src/commands/update/updatePackageJson.ts +45 -41
- package/src/library/babel/index.ts +3 -1
- package/src/models/command.ts +1 -1
- package/src/models/logger.ts +5 -4
- package/src/models/task.ts +1 -1
- package/src/utils/commands/dependencies/getLatestPackageVersion.ts +12 -3
- package/src/utils/commands/dependencies/packageHasVersion.ts +3 -22
- package/lib/utils/commands/dependencies/deduplicate.d.ts +0 -2
- package/lib/utils/commands/dependencies/deduplicate.js +0 -20
- package/lib/utils/commands/dependencies/deduplicate.js.map +0 -1
- package/lib/utils/commands/dependencies/getPackageInfo.d.ts +0 -1
- package/lib/utils/commands/dependencies/getPackageInfo.js +0 -13
- package/lib/utils/commands/dependencies/getPackageInfo.js.map +0 -1
- package/lib/utils/commands/dependencies/installDependencies.d.ts +0 -2
- package/lib/utils/commands/dependencies/installDependencies.js +0 -20
- package/lib/utils/commands/dependencies/installDependencies.js.map +0 -1
- package/lib/utils/commands/dependencies/installDependency.d.ts +0 -6
- package/lib/utils/commands/dependencies/installDependency.js +0 -20
- package/lib/utils/commands/dependencies/installDependency.js.map +0 -1
- package/src/utils/commands/dependencies/deduplicate.ts +0 -16
- package/src/utils/commands/dependencies/getPackageInfo.ts +0 -10
- package/src/utils/commands/dependencies/installDependencies.ts +0 -16
- package/src/utils/commands/dependencies/installDependency.ts +0 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.74.0",
|
|
4
4
|
"description": "Cli инструмент для сборки и запуска приложений",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -64,15 +64,15 @@
|
|
|
64
64
|
"@tinkoff/is-modern-lib": "2.0.6",
|
|
65
65
|
"@tinkoff/logger": "0.10.58",
|
|
66
66
|
"@tinkoff/minicss-class-generator": "0.2.5",
|
|
67
|
-
"@tinkoff/package-manager-wrapper": "0.1.
|
|
67
|
+
"@tinkoff/package-manager-wrapper": "0.1.7",
|
|
68
68
|
"@tinkoff/request-core": "^0.9.2",
|
|
69
69
|
"@tinkoff/request-plugin-protocol-http": "^0.11.6",
|
|
70
70
|
"@tinkoff/utils": "^2.1.3",
|
|
71
71
|
"@tinkoff/webpack-dedupe-plugin": "1.0.2",
|
|
72
72
|
"@tramvai/build": "3.1.2",
|
|
73
|
-
"@tramvai/react": "2.
|
|
73
|
+
"@tramvai/react": "2.74.0",
|
|
74
74
|
"@tramvai/tools-check-versions": "0.4.9",
|
|
75
|
-
"@tramvai/tools-migrate": "0.6.
|
|
75
|
+
"@tramvai/tools-migrate": "0.6.12",
|
|
76
76
|
"ajv": "^6.12.6",
|
|
77
77
|
"ansi-escapes": "^4.3.2",
|
|
78
78
|
"autoprefixer": "^10.4.8",
|
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
"browserslist": "^4.21.3",
|
|
87
87
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
|
88
88
|
"chalk": "^4.1.2",
|
|
89
|
+
"core-js": "^3.0.0",
|
|
89
90
|
"commander": "^6.2.1",
|
|
90
91
|
"compression": "^1.7.4",
|
|
91
92
|
"css-class-generator": "^2.0.0",
|
|
@@ -113,6 +114,7 @@
|
|
|
113
114
|
"inquirer": "^7.3.3",
|
|
114
115
|
"inquirer-autocomplete-prompt": "^1.4.0",
|
|
115
116
|
"inspectpack": "^4.7.1",
|
|
117
|
+
"latest-version": "^5.0.0",
|
|
116
118
|
"less": "^3.13.1",
|
|
117
119
|
"less-loader": "^8.1.1",
|
|
118
120
|
"lightning-pool": "^2.4.0",
|
|
@@ -123,6 +125,7 @@
|
|
|
123
125
|
"null-loader": "^4.0.1",
|
|
124
126
|
"ora": "^5.4.1",
|
|
125
127
|
"p-map": "^4.0.0",
|
|
128
|
+
"package-json": "^6.5.0",
|
|
126
129
|
"path-browserify": "^1.0.1",
|
|
127
130
|
"port-used": "^2.0.8",
|
|
128
131
|
"postcss": "^8.4.16",
|
package/src/cli/bin-init.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import resolve from 'resolve';
|
|
2
2
|
import { clearExecArgv } from '../utils/clearExecArgv';
|
|
3
|
-
import { fixYarnSettingsOverride } from '../utils/fixYarnSettingsOverride';
|
|
4
|
-
import { handleErrors } from '../utils/handleErrors';
|
|
5
3
|
import { initSentry } from '../utils/sentry';
|
|
6
4
|
|
|
7
5
|
clearExecArgv();
|
|
8
6
|
initSentry();
|
|
9
|
-
handleErrors();
|
|
10
|
-
fixYarnSettingsOverride();
|
|
11
7
|
|
|
12
8
|
resolve(
|
|
13
9
|
'@tramvai/cli/lib/cli',
|
package/src/cli/runCLI.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
// to use V8's code cache to speed up instantiation time
|
|
2
1
|
import exit from 'exit';
|
|
3
2
|
|
|
3
|
+
import { fixYarnSettingsOverride } from '../utils/fixYarnSettingsOverride';
|
|
4
|
+
import { handleErrors } from '../utils/handleErrors';
|
|
5
|
+
|
|
6
|
+
// to use V8's code cache to speed up instantiation time
|
|
4
7
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
5
8
|
import('v8-compile-cache');
|
|
6
9
|
|
|
10
|
+
handleErrors();
|
|
11
|
+
fixYarnSettingsOverride();
|
|
12
|
+
|
|
7
13
|
export default (pathCli: string) => {
|
|
8
14
|
const cli = require(pathCli).cliInitialized;
|
|
9
15
|
|
package/src/commands/add/add.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { Context } from '../../models/context';
|
|
2
2
|
import type { CommandResult } from '../../models/command';
|
|
3
|
-
import { installDependency } from '../../utils/commands/dependencies/installDependency';
|
|
4
|
-
import { deduplicate } from '../../utils/commands/dependencies/deduplicate';
|
|
5
3
|
import { migrate } from '../../utils/commands/dependencies/migrate';
|
|
6
4
|
import { findTramvaiVersion } from '../../utils/commands/dependencies/findTramvaiVersion';
|
|
7
5
|
import { checkVersions } from '../../utils/commands/dependencies/checkVersions';
|
|
@@ -14,9 +12,24 @@ export type Params = {
|
|
|
14
12
|
export default async (context: Context, { packageName, dev }: Params): Promise<CommandResult> => {
|
|
15
13
|
const version = await findTramvaiVersion();
|
|
16
14
|
|
|
17
|
-
await
|
|
15
|
+
await context.packageManager.install({
|
|
16
|
+
name: packageName,
|
|
17
|
+
version,
|
|
18
|
+
devDependency: dev,
|
|
19
|
+
stdio: 'inherit',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
if (context.packageManager.name !== 'npm') {
|
|
23
|
+
// npm dedupe is extremely slow in most cases
|
|
24
|
+
// so execute it only for yarn
|
|
25
|
+
context.logger.event({
|
|
26
|
+
type: 'info',
|
|
27
|
+
event: 'dedupe',
|
|
28
|
+
message: 'Deduplicate dependencies',
|
|
29
|
+
});
|
|
18
30
|
|
|
19
|
-
|
|
31
|
+
await context.packageManager.dedupe({ stdio: 'inherit' });
|
|
32
|
+
}
|
|
20
33
|
|
|
21
34
|
await migrate(context);
|
|
22
35
|
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import childProcess from 'child_process';
|
|
1
|
+
import latestVersion from 'latest-version';
|
|
3
2
|
import type { Params } from './add';
|
|
4
3
|
|
|
5
|
-
const exec = util.promisify(childProcess.exec);
|
|
6
|
-
|
|
7
4
|
export const checkPackage = async (_, { packageName }: Params) => {
|
|
8
5
|
try {
|
|
9
|
-
await
|
|
6
|
+
await latestVersion(packageName);
|
|
10
7
|
} catch (e) {
|
|
11
8
|
throw new Error(`Package ${packageName} does not exists`);
|
|
12
9
|
}
|
|
@@ -71,6 +71,15 @@ export const staticApp = async (
|
|
|
71
71
|
},
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
+
server.catch((reason) => {
|
|
75
|
+
context.logger.event({
|
|
76
|
+
type: 'error',
|
|
77
|
+
event: 'COMMAND:STATIC:BUILD',
|
|
78
|
+
message: `message: server.js launch failed`,
|
|
79
|
+
payload: reason,
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
74
83
|
const bundleInfoPath = `http://localhost:${port}/${name}/papi/bundleInfo`;
|
|
75
84
|
|
|
76
85
|
await Promise.race([
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import getLatestPackageVersion from 'latest-version';
|
|
2
|
+
import getPackageInfo from 'package-json';
|
|
3
3
|
|
|
4
4
|
// map of packages that is not in unified versioning
|
|
5
5
|
// but we still want to update it
|
|
@@ -34,9 +34,9 @@ export const getLibPackageVersion = async (
|
|
|
34
34
|
return getLatestPackageVersion(name);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
const
|
|
37
|
+
const { dependencies } = await getPackageInfo(unifiedModule, { version: unifiedVersion });
|
|
38
38
|
|
|
39
|
-
if (!
|
|
39
|
+
if (!dependencies[name]) {
|
|
40
40
|
console.warn(
|
|
41
41
|
`⚠️ cannot resolve proper version for the "${name}" package.
|
|
42
42
|
You have to update this package by yourself.`
|
|
@@ -45,5 +45,5 @@ You have to update this package by yourself.`
|
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
return
|
|
48
|
+
return dependencies[name];
|
|
49
49
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { Context } from '../../models/context';
|
|
2
2
|
import type { CommandResult } from '../../models/command';
|
|
3
|
-
import { installDependencies } from '../../utils/commands/dependencies/installDependencies';
|
|
4
3
|
import { getLatestPackageVersion } from '../../utils/commands/dependencies/getLatestPackageVersion';
|
|
5
|
-
import { deduplicate } from '../../utils/commands/dependencies/deduplicate';
|
|
6
4
|
import { migrate } from '../../utils/commands/dependencies/migrate';
|
|
7
5
|
import { updatePackageJson } from './updatePackageJson';
|
|
8
6
|
import { checkVersions } from '../../utils/commands/dependencies/checkVersions';
|
|
@@ -15,21 +13,49 @@ export default async (
|
|
|
15
13
|
context: Context,
|
|
16
14
|
{ to: version = 'latest' }: Params
|
|
17
15
|
): Promise<CommandResult> => {
|
|
18
|
-
const versionNumber =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
const versionNumber = await getLatestPackageVersion('@tramvai/core', version);
|
|
17
|
+
|
|
18
|
+
context.logger.event({
|
|
19
|
+
type: 'info',
|
|
20
|
+
event: 'resolving-version',
|
|
21
|
+
message: `Tramvai version resolved to ${versionNumber}`,
|
|
22
|
+
});
|
|
22
23
|
|
|
23
24
|
await updatePackageJson(versionNumber);
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
context.logger.event({
|
|
27
|
+
type: 'info',
|
|
28
|
+
event: 'install',
|
|
29
|
+
message: 'Installing dependencies',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
await context.packageManager.install({ stdio: 'inherit' });
|
|
33
|
+
|
|
34
|
+
if (context.packageManager.name !== 'npm') {
|
|
35
|
+
// npm dedupe is extremely slow in most cases
|
|
36
|
+
// so execute it only for yarn
|
|
37
|
+
context.logger.event({
|
|
38
|
+
type: 'info',
|
|
39
|
+
event: 'dedupe',
|
|
40
|
+
message: 'Deduplicate dependencies',
|
|
41
|
+
});
|
|
26
42
|
|
|
27
|
-
|
|
43
|
+
await context.packageManager.dedupe({ stdio: 'inherit' });
|
|
44
|
+
}
|
|
28
45
|
|
|
29
46
|
await migrate(context);
|
|
30
47
|
|
|
31
48
|
await checkVersions(context);
|
|
32
49
|
|
|
50
|
+
if (context.packageManager.name === 'npm') {
|
|
51
|
+
context.logger.event({
|
|
52
|
+
type: 'warning',
|
|
53
|
+
event: 'dedupe',
|
|
54
|
+
message:
|
|
55
|
+
'To make sure the node_modules tree is optimized you can additionaly run `npm dedupe` command',
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
33
59
|
return Promise.resolve({
|
|
34
60
|
status: 'ok',
|
|
35
61
|
});
|
|
@@ -10,23 +10,17 @@ const mockPackageInfoDependencies = jest.fn<Record<string, string | undefined>,
|
|
|
10
10
|
jest.mock('../../utils/commands/dependencies/packageHasVersion', () => ({
|
|
11
11
|
packageHasVersion: () => true,
|
|
12
12
|
}));
|
|
13
|
-
jest.mock('
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
13
|
+
jest.mock('latest-version', () => (dep: string) => {
|
|
14
|
+
if (dep.startsWith('@tramvai')) {
|
|
15
|
+
return LATEST_TRAMVAI_VERSION;
|
|
16
|
+
}
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}));
|
|
18
|
+
return LATEST_LIB_VERSION;
|
|
19
|
+
});
|
|
22
20
|
|
|
23
|
-
jest.mock('
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return mockPackageInfoDependencies(packageName);
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
}));
|
|
21
|
+
jest.mock('package-json', () => (packageName: string) => {
|
|
22
|
+
return { dependencies: mockPackageInfoDependencies(packageName) };
|
|
23
|
+
});
|
|
30
24
|
|
|
31
25
|
jest.mock('fs', () => ({
|
|
32
26
|
readFileSync: () => JSON.stringify(mockPackageJson),
|
|
@@ -54,18 +48,18 @@ it('should update tramvai deps to latest versions', async () => {
|
|
|
54
48
|
},
|
|
55
49
|
};
|
|
56
50
|
|
|
57
|
-
mockPackageInfoDependencies.mockImplementation((dep) => {
|
|
51
|
+
mockPackageInfoDependencies.mockImplementation((dep: string) => {
|
|
58
52
|
switch (dep) {
|
|
59
|
-
case '@tramvai/core
|
|
53
|
+
case '@tramvai/core':
|
|
60
54
|
return { '@tinkoff/dippy': '0.7.44', '@tinkoff/utils': '^2.1.0' };
|
|
61
|
-
case '@tramvai/module-common
|
|
55
|
+
case '@tramvai/module-common':
|
|
62
56
|
return {
|
|
63
57
|
'@tinkoff/error': '0.6.1',
|
|
64
58
|
'@tinkoff/url': '0.4.1',
|
|
65
59
|
};
|
|
66
|
-
case '@tramvai/cli
|
|
60
|
+
case '@tramvai/cli':
|
|
67
61
|
return {};
|
|
68
|
-
case '@tramvai/module-router
|
|
62
|
+
case '@tramvai/module-router':
|
|
69
63
|
return {
|
|
70
64
|
'@tinkoff/router': '0.4.3',
|
|
71
65
|
'@tinkoff/url': '0.4.1',
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { parse, minVersion } from 'semver';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import pMap from 'p-map';
|
|
4
|
+
import type { Ora } from 'ora';
|
|
5
|
+
import ora from 'ora';
|
|
4
6
|
import { packageHasVersion } from '../../utils/commands/dependencies/packageHasVersion';
|
|
5
7
|
import { getLibPackageVersion, isDependantLib } from './dependantLibs';
|
|
6
8
|
|
|
@@ -10,47 +12,45 @@ const isUnifiedVersion = (name: string) => {
|
|
|
10
12
|
|
|
11
13
|
const getVersionFromDep = (dep: string) => parse(dep)?.version || minVersion(dep)?.version;
|
|
12
14
|
|
|
13
|
-
const updateEntry = async (
|
|
14
|
-
deps: Record<string, any>,
|
|
15
|
-
dep: string,
|
|
16
|
-
{ currentVersion, version }: { currentVersion: string; version: string }
|
|
17
|
-
) => {
|
|
18
|
-
let nextVersion: string | undefined;
|
|
19
|
-
|
|
20
|
-
if (isUnifiedVersion(dep) && getVersionFromDep(deps[dep]) === currentVersion) {
|
|
21
|
-
nextVersion = version;
|
|
22
|
-
} else if (isDependantLib(dep)) {
|
|
23
|
-
const libVersion = await getLibPackageVersion(dep, version);
|
|
24
|
-
nextVersion = libVersion;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (nextVersion) {
|
|
28
|
-
const depHasVersion = await packageHasVersion(dep, nextVersion);
|
|
29
|
-
|
|
30
|
-
if (depHasVersion) {
|
|
31
|
-
console.log(`- ${dep}@${nextVersion}`);
|
|
32
|
-
// eslint-disable-next-line no-param-reassign
|
|
33
|
-
deps[dep] = nextVersion;
|
|
34
|
-
} else {
|
|
35
|
-
console.warn(
|
|
36
|
-
`⚠️ cannot update ${dep} to ${nextVersion} version, this version does not exist.
|
|
37
|
-
Maybe this package was removed or renamed.
|
|
38
|
-
Wait migrations, then manually update or remove dependency from package.json, if necessary.`
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
15
|
const updateDependencies = (
|
|
45
16
|
dependencies: Record<string, string> = {},
|
|
46
17
|
targetVersion: string,
|
|
47
|
-
currentVersion: string
|
|
18
|
+
currentVersion: string,
|
|
19
|
+
spinner: Ora
|
|
48
20
|
) => {
|
|
49
21
|
return pMap<string, void>(
|
|
50
22
|
Object.keys(dependencies),
|
|
51
23
|
async (dep) => {
|
|
52
|
-
|
|
53
|
-
|
|
24
|
+
let nextVersion: string | undefined;
|
|
25
|
+
|
|
26
|
+
if (isUnifiedVersion(dep) && getVersionFromDep(dependencies[dep]) === currentVersion) {
|
|
27
|
+
nextVersion = targetVersion;
|
|
28
|
+
} else if (isDependantLib(dep)) {
|
|
29
|
+
const libVersion = await getLibPackageVersion(dep, targetVersion);
|
|
30
|
+
nextVersion = libVersion;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (nextVersion) {
|
|
34
|
+
const depHasVersion = await packageHasVersion(dep, nextVersion);
|
|
35
|
+
|
|
36
|
+
// clear the spinner to be able to log info that should be preserved in the output
|
|
37
|
+
// the idea borrowed from [here](https://github.com/sindresorhus/ora/issues/120)
|
|
38
|
+
spinner.clear();
|
|
39
|
+
|
|
40
|
+
if (depHasVersion) {
|
|
41
|
+
console.log(`- ${dep}@${nextVersion}`);
|
|
42
|
+
// eslint-disable-next-line no-param-reassign
|
|
43
|
+
dependencies[dep] = nextVersion;
|
|
44
|
+
} else {
|
|
45
|
+
console.warn(
|
|
46
|
+
`⚠️ cannot update ${dep} to ${nextVersion} version, this version does not exist.
|
|
47
|
+
Maybe this package was removed or renamed.
|
|
48
|
+
Wait migrations, then manually update or remove dependency from package.json, if necessary.`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// start the spinner back with the initial text
|
|
53
|
+
spinner.start(spinner.text);
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
{
|
|
@@ -60,8 +60,6 @@ const updateDependencies = (
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
export const updatePackageJson = async (version: string) => {
|
|
63
|
-
console.log(`Update package.json to ${version} version`);
|
|
64
|
-
|
|
65
63
|
const file = fs.readFileSync('package.json');
|
|
66
64
|
const content = JSON.parse(file.toString());
|
|
67
65
|
const currentVersion = getVersionFromDep(content.dependencies['@tramvai/core']);
|
|
@@ -72,12 +70,18 @@ export const updatePackageJson = async (version: string) => {
|
|
|
72
70
|
|
|
73
71
|
if (currentVersion === version) {
|
|
74
72
|
console.error('The installed version is equal to the current version, no update is required.');
|
|
75
|
-
|
|
73
|
+
return;
|
|
76
74
|
}
|
|
77
75
|
|
|
78
|
-
|
|
79
|
-
await updateDependencies(content.devDependencies, version, currentVersion);
|
|
80
|
-
await updateDependencies(content.peerDependencies, version, currentVersion);
|
|
76
|
+
const spinner = ora(`Updating package.json versions`).start();
|
|
81
77
|
|
|
82
|
-
|
|
78
|
+
try {
|
|
79
|
+
await updateDependencies(content.dependencies, version, currentVersion, spinner);
|
|
80
|
+
await updateDependencies(content.devDependencies, version, currentVersion, spinner);
|
|
81
|
+
await updateDependencies(content.peerDependencies, version, currentVersion, spinner);
|
|
82
|
+
|
|
83
|
+
fs.writeFileSync('package.json', JSON.stringify(content, null, 2));
|
|
84
|
+
} finally {
|
|
85
|
+
spinner.stop();
|
|
86
|
+
}
|
|
83
87
|
};
|
|
@@ -84,7 +84,9 @@ export const babelConfigFactory = ({
|
|
|
84
84
|
{
|
|
85
85
|
modules,
|
|
86
86
|
useBuiltIns: 'entry',
|
|
87
|
-
|
|
87
|
+
// from core-js version depends what polyfills will be included with `useBuiltIns: 'entry'` option
|
|
88
|
+
// this logic is here - https://github.com/zloirock/core-js/blob/master/packages/core-js-compat/src/modules-by-versions.mjs
|
|
89
|
+
corejs: require('core-js/package.json').version,
|
|
88
90
|
loose: true,
|
|
89
91
|
targets,
|
|
90
92
|
browserslistEnv: resultTarget,
|
package/src/models/command.ts
CHANGED
package/src/models/logger.ts
CHANGED
|
@@ -2,16 +2,17 @@ interface LogEvent {
|
|
|
2
2
|
type: 'error' | 'warning' | 'info' | 'debug';
|
|
3
3
|
event: string; // уникальный идентификатор
|
|
4
4
|
message: string;
|
|
5
|
+
payload?: any;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
export class Logger {
|
|
8
9
|
event(event: LogEvent): void {
|
|
9
10
|
if (event.type === 'error') {
|
|
10
|
-
console.error(event.type, event.event, event.message);
|
|
11
|
+
console.error(event.type, event.event, event.message, event.payload);
|
|
11
12
|
} else if (event.type === 'warning') {
|
|
12
|
-
console.warn(event.type, event.event, event.message);
|
|
13
|
-
} else if (process.env.DEBUG_MODE === 'true') {
|
|
14
|
-
console.log(event.type, event.event, event.message);
|
|
13
|
+
console.warn(event.type, event.event, event.message, event.payload);
|
|
14
|
+
} else if (event.type === 'info' || process.env.DEBUG_MODE === 'true') {
|
|
15
|
+
console.log(event.type, event.event, event.message, event.payload);
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
}
|
package/src/models/task.ts
CHANGED
|
@@ -34,7 +34,7 @@ export abstract class Task {
|
|
|
34
34
|
parameters: { arguments?: string[]; options?: Record<string, any> } = {}
|
|
35
35
|
): Promise<TaskResult> {
|
|
36
36
|
this.context.logger.event({
|
|
37
|
-
type: '
|
|
37
|
+
type: 'debug',
|
|
38
38
|
event: `RUN:TASK:${this.name}`,
|
|
39
39
|
message: JSON.stringify(parameters),
|
|
40
40
|
});
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ora from 'ora';
|
|
2
|
+
import latestVersion from 'latest-version';
|
|
2
3
|
|
|
3
|
-
export const getLatestPackageVersion = async (packageName: string,
|
|
4
|
-
|
|
4
|
+
export const getLatestPackageVersion = async (packageName: string, version = 'latest') => {
|
|
5
|
+
const spinner = ora(`Resolving the highest version satifying to ${version}`).start();
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
const result = await latestVersion(packageName, { version });
|
|
9
|
+
|
|
10
|
+
return result;
|
|
11
|
+
} finally {
|
|
12
|
+
spinner.stop();
|
|
13
|
+
}
|
|
5
14
|
};
|
|
@@ -1,29 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import childProcess from 'child_process';
|
|
3
|
-
import ora from 'ora';
|
|
4
|
-
|
|
5
|
-
const exec = util.promisify(childProcess.exec);
|
|
6
|
-
|
|
7
|
-
const addPaddingToString = (text: string) =>
|
|
8
|
-
text
|
|
9
|
-
.split('\n')
|
|
10
|
-
.map((line) => ` ${line}`)
|
|
11
|
-
.join('\n');
|
|
1
|
+
import latestVersion from 'latest-version';
|
|
12
2
|
|
|
13
3
|
export const packageHasVersion = async (packageName: string, version: string): Promise<boolean> => {
|
|
14
|
-
const spinner = ora(`Checking is ${packageName} package has ${version} version`).start();
|
|
15
|
-
|
|
16
4
|
try {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
spinner.stop();
|
|
20
|
-
return hasVersion;
|
|
5
|
+
await latestVersion(packageName, { version });
|
|
6
|
+
return true;
|
|
21
7
|
} 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`);
|
|
27
8
|
return false;
|
|
28
9
|
}
|
|
29
10
|
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deduplicate = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const ora_1 = tslib_1.__importDefault(require("ora"));
|
|
6
|
-
const deduplicate = (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
7
|
-
const spinner = (0, ora_1.default)('Deduplicate dependencies in a lock file').start();
|
|
8
|
-
try {
|
|
9
|
-
yield context.packageManager.dedupe();
|
|
10
|
-
spinner.stop();
|
|
11
|
-
console.log('Deduplication completed');
|
|
12
|
-
}
|
|
13
|
-
catch (e) {
|
|
14
|
-
spinner.stop();
|
|
15
|
-
console.error('Deduplication error:');
|
|
16
|
-
throw e;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
exports.deduplicate = deduplicate;
|
|
20
|
-
//# sourceMappingURL=deduplicate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deduplicate.js","sourceRoot":"","sources":["../../../../src/utils/commands/dependencies/deduplicate.ts"],"names":[],"mappings":";;;;AAAA,sDAAsB;AAGf,MAAM,WAAW,GAAG,CAAO,OAAgB,EAAE,EAAE;IACpD,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC,yCAAyC,CAAC,CAAC,KAAK,EAAE,CAAC;IAEvE,IAAI;QACF,MAAM,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;QACtC,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;KACxC;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACtC,MAAM,CAAC,CAAC;KACT;AACH,CAAC,CAAA,CAAC;AAZW,QAAA,WAAW,eAYtB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getPackageInfo: (packageName: string, field?: string) => Promise<any>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPackageInfo = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const util_1 = tslib_1.__importDefault(require("util"));
|
|
6
|
-
const child_process_1 = tslib_1.__importDefault(require("child_process"));
|
|
7
|
-
const exec = util_1.default.promisify(child_process_1.default.exec);
|
|
8
|
-
const getPackageInfo = (packageName, field) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
-
const { stdout } = yield exec(`npm view ${packageName} --json ${field !== null && field !== void 0 ? field : ''}`);
|
|
10
|
-
return JSON.parse(stdout);
|
|
11
|
-
});
|
|
12
|
-
exports.getPackageInfo = getPackageInfo;
|
|
13
|
-
//# sourceMappingURL=getPackageInfo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageInfo.js","sourceRoot":"","sources":["../../../../src/utils/commands/dependencies/getPackageInfo.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AACxB,0EAAyC;AAEzC,MAAM,IAAI,GAAG,cAAI,CAAC,SAAS,CAAC,uBAAY,CAAC,IAAI,CAAC,CAAC;AAExC,MAAM,cAAc,GAAG,CAAO,WAAmB,EAAE,KAAc,EAAE,EAAE;IAC1E,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,YAAY,WAAW,WAAW,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,EAAE,CAAC,CAAC;IAE/E,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC,CAAA,CAAC;AAJW,QAAA,cAAc,kBAIzB"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.installDependencies = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const ora_1 = tslib_1.__importDefault(require("ora"));
|
|
6
|
-
const installDependencies = (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
7
|
-
const spinner = (0, ora_1.default)('Install dependencies...').start();
|
|
8
|
-
try {
|
|
9
|
-
yield context.packageManager.install();
|
|
10
|
-
spinner.stop();
|
|
11
|
-
console.log('Dependencies installed');
|
|
12
|
-
}
|
|
13
|
-
catch (e) {
|
|
14
|
-
spinner.stop();
|
|
15
|
-
console.error('Error installing dependencies:');
|
|
16
|
-
throw e;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
exports.installDependencies = installDependencies;
|
|
20
|
-
//# sourceMappingURL=installDependencies.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"installDependencies.js","sourceRoot":"","sources":["../../../../src/utils/commands/dependencies/installDependencies.ts"],"names":[],"mappings":";;;;AAAA,sDAAsB;AAGf,MAAM,mBAAmB,GAAG,CAAO,OAAgB,EAAE,EAAE;IAC5D,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC,yBAAyB,CAAC,CAAC,KAAK,EAAE,CAAC;IAEvD,IAAI;QACF,MAAM,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;QACvC,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;KACvC;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;QAChD,MAAM,CAAC,CAAC;KACT;AACH,CAAC,CAAA,CAAC;AAZW,QAAA,mBAAmB,uBAY9B"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.installDependency = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const ora_1 = tslib_1.__importDefault(require("ora"));
|
|
6
|
-
const installDependency = ({ name, version, devDependency }, context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
7
|
-
const spinner = (0, ora_1.default)(`Install ${name}@${version}`).start();
|
|
8
|
-
try {
|
|
9
|
-
yield context.packageManager.install({ name, version, devDependency });
|
|
10
|
-
spinner.stop();
|
|
11
|
-
console.log(`${name}@${version} installed`);
|
|
12
|
-
}
|
|
13
|
-
catch (e) {
|
|
14
|
-
spinner.stop();
|
|
15
|
-
console.error(`Error installing ${name}@${version}: `, e);
|
|
16
|
-
throw e;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
exports.installDependency = installDependency;
|
|
20
|
-
//# sourceMappingURL=installDependency.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"installDependency.js","sourceRoot":"","sources":["../../../../src/utils/commands/dependencies/installDependency.ts"],"names":[],"mappings":";;;;AAAA,sDAAsB;AAGf,MAAM,iBAAiB,GAAG,CAC/B,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,EAA8D,EAC5F,OAAgB,EAChB,EAAE;IACF,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC,WAAW,IAAI,IAAI,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;IAE1D,IAAI;QACF,MAAM,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;QACvE,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,OAAO,YAAY,CAAC,CAAC;KAC7C;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,oBAAoB,IAAI,IAAI,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;QAC1D,MAAM,CAAC,CAAC;KACT;AACH,CAAC,CAAA,CAAC;AAfW,QAAA,iBAAiB,qBAe5B"}
|