@tramvai/cli 2.7.1 → 2.20.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/README.md +12 -0
- package/lib/api/analyze/index.d.ts +1 -0
- package/lib/api/analyze/index.js.map +1 -1
- package/lib/api/build/index.d.ts +1 -0
- package/lib/api/build/index.js.map +1 -1
- package/lib/api/start/index.d.ts +1 -0
- package/lib/api/start/index.js.map +1 -1
- package/lib/api/start/tokens.d.ts +4 -4
- package/lib/api/start/utils/banner.js +1 -1
- package/lib/api/start/utils/banner.js.map +1 -1
- package/lib/api/start-prod/index.d.ts +1 -0
- package/lib/api/start-prod/index.js.map +1 -1
- package/lib/api/start-prod/tokens.d.ts +4 -4
- package/lib/builder/webpack/providers/analyze/shared.js +23 -24
- package/lib/builder/webpack/providers/analyze/shared.js.map +1 -1
- package/lib/builder/webpack/tokens.d.ts +18 -18
- package/lib/commands/analyze/command.d.ts +8 -0
- package/lib/commands/analyze/command.js +6 -0
- package/lib/commands/analyze/command.js.map +1 -1
- package/lib/commands/build/command.js +6 -0
- package/lib/commands/build/command.js.map +1 -1
- package/lib/commands/index.d.ts +1 -1
- package/lib/commands/new/steps/initializationGit.js +2 -2
- package/lib/commands/new/steps/initializationGit.js.map +1 -1
- package/lib/commands/new/steps/installDependencies.js +10 -6
- package/lib/commands/new/steps/installDependencies.js.map +1 -1
- package/lib/commands/new/steps/renderTemplate.js +1 -1
- package/lib/commands/new/steps/renderTemplate.js.map +1 -1
- package/lib/commands/new/utils/applyTemplate.js +1 -1
- package/lib/commands/new/utils/applyTemplate.js.map +1 -1
- package/lib/commands/start/command.js +6 -0
- package/lib/commands/start/command.js.map +1 -1
- package/lib/commands/start-prod/command.js +6 -0
- package/lib/commands/start-prod/command.js.map +1 -1
- package/lib/commands/static/command.d.ts +6 -0
- package/lib/commands/static/command.js +6 -0
- package/lib/commands/static/command.js.map +1 -1
- package/lib/commands/update/dependantLibs.d.ts +2 -0
- package/lib/commands/update/dependantLibs.js +43 -0
- package/lib/commands/update/dependantLibs.js.map +1 -0
- package/lib/commands/update/updatePackageJson.js +7 -24
- package/lib/commands/update/updatePackageJson.js.map +1 -1
- package/lib/config/configManager.d.ts +3 -0
- package/lib/config/configManager.js +10 -7
- package/lib/config/configManager.js.map +1 -1
- package/lib/di/tokens/analytics.d.ts +3 -3
- package/lib/di/tokens/builder.d.ts +4 -4
- package/lib/di/tokens/command.d.ts +5 -5
- package/lib/di/tokens/config.d.ts +5 -5
- package/lib/di/tokens/logger.d.ts +1 -1
- package/lib/di/tokens/packageManager.d.ts +2 -2
- package/lib/di/tokens/server.d.ts +2 -2
- package/lib/di/tokens/std.d.ts +2 -2
- package/lib/di/tokens/ui.d.ts +3 -3
- package/lib/external/pages.d.ts +3 -5
- package/lib/external/pages.js.map +1 -1
- package/lib/library/babel/plugins/create-token-pure.d.ts +4 -1
- package/lib/library/babel/plugins/create-token-pure.js +5 -3
- package/lib/library/babel/plugins/create-token-pure.js.map +1 -1
- package/lib/library/webpack/application/client/common.js +1 -1
- package/lib/library/webpack/application/client/common.js.map +1 -1
- package/lib/library/webpack/application/server/common.js +1 -1
- package/lib/library/webpack/application/server/common.js.map +1 -1
- package/lib/library/webpack/blocks/configToEnv.js +1 -1
- package/lib/library/webpack/blocks/configToEnv.js.map +1 -1
- package/lib/library/webpack/blocks/filesClient.js +5 -2
- package/lib/library/webpack/blocks/filesClient.js.map +1 -1
- package/lib/library/webpack/blocks/filesServer.js +9 -5
- package/lib/library/webpack/blocks/filesServer.js.map +1 -1
- package/lib/library/webpack/blocks/pagesResolve.js +1 -1
- package/lib/library/webpack/blocks/pagesResolve.js.map +1 -1
- package/lib/library/webpack/common/main.js +17 -16
- package/lib/library/webpack/common/main.js.map +1 -1
- package/lib/library/webpack/loaders/image-loader/index.d.ts +5 -0
- package/lib/library/webpack/loaders/image-loader/index.js +25 -0
- package/lib/library/webpack/loaders/image-loader/index.js.map +1 -0
- package/lib/schema/autogeneratedSchema.json +165 -294
- package/lib/typings/configEntry/common.d.ts +169 -175
- package/lib/utils/commands/dependencies/checkVersions.js +3 -11
- package/lib/utils/commands/dependencies/checkVersions.js.map +1 -1
- package/lib/utils/commands/dependencies/getLatestPackageVersion.d.ts +1 -1
- package/lib/utils/commands/dependencies/getLatestPackageVersion.js +2 -6
- package/lib/utils/commands/dependencies/getLatestPackageVersion.js.map +1 -1
- package/lib/utils/commands/dependencies/getPackageInfo.d.ts +1 -0
- package/lib/utils/commands/dependencies/getPackageInfo.js +13 -0
- package/lib/utils/commands/dependencies/getPackageInfo.js.map +1 -0
- package/lib/utils/commands/dependencies/migrate.js +3 -11
- package/lib/utils/commands/dependencies/migrate.js.map +1 -1
- package/lib/utils/npmRequire.d.ts +15 -0
- package/lib/utils/npmRequire.js +15 -0
- package/lib/utils/npmRequire.js.map +1 -1
- package/lib/utils/shouldUseReactRoot.js +3 -3
- package/lib/utils/shouldUseReactRoot.js.map +1 -1
- package/lib/validators/commands/runMigrationsAndCheckVersions.js +3 -7
- package/lib/validators/commands/runMigrationsAndCheckVersions.js.map +1 -1
- package/package.json +89 -86
- package/schema.json +165 -294
- package/src/api/analyze/index.ts +1 -0
- package/src/api/build/__integration__/__fixtures__/tramvai.json +3 -0
- package/src/api/build/__integration__/build.test.ts +1 -0
- package/src/api/build/index.ts +1 -0
- package/src/api/start/__integration__/__fixtures__/tramvai.json +2 -4
- package/src/api/start/index.ts +1 -0
- package/src/api/start/utils/banner.ts +1 -1
- package/src/api/start-prod/index.ts +1 -0
- package/src/builder/webpack/providers/analyze/shared.ts +1 -1
- package/src/commands/analyze/command.ts +6 -0
- package/src/commands/build/command.ts +6 -0
- package/src/commands/generate/generators/action/action.ts.hbs +4 -4
- package/src/commands/new/steps/initializationGit.ts +3 -2
- package/src/commands/new/steps/installDependencies.ts +15 -8
- package/src/commands/new/steps/renderTemplate.ts +1 -1
- package/src/commands/new/templates/app/monorepo/tramvai.json.hbs +2 -4
- package/src/commands/new/templates/app/multirepo/tramvai.json.hbs +2 -4
- package/src/commands/new/templates/shared/_npmrc.hbs +0 -1
- package/src/commands/new/utils/applyTemplate.ts +5 -1
- package/src/commands/start/command.ts +6 -0
- package/src/commands/start-prod/command.ts +6 -0
- package/src/commands/static/command.ts +6 -0
- package/src/commands/update/dependantLibs.ts +49 -0
- package/src/commands/update/updatePackageJson.spec.ts +99 -0
- package/src/commands/update/updatePackageJson.ts +7 -25
- package/src/config/configManager.ts +9 -3
- package/src/external/pages.ts +3 -5
- package/src/library/babel/plugins/__fixtures__/create-token-pure/already-has-comment.ts +5 -0
- package/src/library/babel/plugins/__snapshots__/create-token-pure.spec.ts.snap +18 -0
- package/src/library/babel/plugins/create-token-pure.spec.ts +4 -0
- package/src/library/babel/plugins/create-token-pure.ts +9 -4
- package/src/library/webpack/application/client/common.ts +1 -3
- package/src/library/webpack/application/server/common.ts +1 -3
- package/src/library/webpack/blocks/configToEnv.ts +1 -1
- package/src/library/webpack/blocks/filesClient.ts +5 -2
- package/src/library/webpack/blocks/filesServer.ts +8 -5
- package/src/library/webpack/blocks/pagesResolve.ts +1 -1
- package/src/library/webpack/common/main.ts +19 -18
- package/src/library/webpack/loaders/image-loader/index.ts +26 -0
- package/src/schema/autogeneratedSchema.json +165 -294
- package/src/schema/tramvai.spec.ts +146 -148
- package/src/typings/configEntry/common.ts +171 -175
- package/src/utils/commands/dependencies/checkVersions.ts +3 -13
- package/src/utils/commands/dependencies/getLatestPackageVersion.ts +2 -7
- package/src/utils/commands/dependencies/getPackageInfo.ts +10 -0
- package/src/utils/commands/dependencies/migrate.ts +3 -13
- package/src/utils/npmRequire.ts +15 -0
- package/src/utils/shouldUseReactRoot.ts +4 -4
- package/src/validators/commands/runMigrationsAndCheckVersions.ts +3 -8
- package/lib/utils/commands/dependencies/update.d.ts +0 -7
- package/lib/utils/commands/dependencies/update.js +0 -19
- package/lib/utils/commands/dependencies/update.js.map +0 -1
- package/lib/utils/commands/dependencies/updatePackageJson.d.ts +0 -1
- package/lib/utils/commands/dependencies/updatePackageJson.js +0 -57
- package/lib/utils/commands/dependencies/updatePackageJson.js.map +0 -1
- package/src/utils/commands/dependencies/update.ts +0 -31
- package/src/utils/commands/dependencies/updatePackageJson.ts +0 -63
|
@@ -3,7 +3,6 @@ import { provide } from '@tinkoff/dippy';
|
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import rimraf from 'rimraf';
|
|
5
5
|
import webpack from 'webpack';
|
|
6
|
-
import { INIT_HANDLER_TOKEN } from '../../../../api/start/tokens';
|
|
7
6
|
import {
|
|
8
7
|
CLI_PACKAGE_MANAGER,
|
|
9
8
|
CLI_ROOT_DIR_TOKEN,
|
|
@@ -16,6 +15,7 @@ import { StatoscopeAnalyzePlugin } from '../../analyzePlugins/statoscope';
|
|
|
16
15
|
import { WhyBundledAnalyzePlugin } from '../../analyzePlugins/whyBundled';
|
|
17
16
|
import {
|
|
18
17
|
CLIENT_CONFIG_MANAGER_TOKEN,
|
|
18
|
+
INIT_HANDLER_TOKEN,
|
|
19
19
|
CLOSE_HANDLER_TOKEN,
|
|
20
20
|
PROCESS_HANDLER_TOKEN,
|
|
21
21
|
WEBPACK_ANALYZE_PLUGIN_NAME_TOKEN,
|
|
@@ -28,6 +28,12 @@ class AnalyzeCommand extends CLICommand<Params> {
|
|
|
28
28
|
value: '[showConfig]',
|
|
29
29
|
description: 'Show config with which cli was launched',
|
|
30
30
|
},
|
|
31
|
+
{
|
|
32
|
+
name: '--fileCache',
|
|
33
|
+
value: '[fileCache]',
|
|
34
|
+
transformer: (value) => value !== 'false',
|
|
35
|
+
description: 'Enable/disable persistent file cache for used cli builder',
|
|
36
|
+
},
|
|
31
37
|
];
|
|
32
38
|
|
|
33
39
|
alias = 'a';
|
|
@@ -50,6 +50,12 @@ class BuildCommand extends CLICommand<Params> {
|
|
|
50
50
|
value: '[forPublish]',
|
|
51
51
|
description: '<package> Prepare library package.json for publication',
|
|
52
52
|
},
|
|
53
|
+
{
|
|
54
|
+
name: '--fileCache',
|
|
55
|
+
value: '[fileCache]',
|
|
56
|
+
transformer: (value) => value !== 'false',
|
|
57
|
+
description: 'Enable/disable persistent file cache for used cli builder',
|
|
58
|
+
},
|
|
53
59
|
];
|
|
54
60
|
|
|
55
61
|
alias = 'b';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { declareAction } from '@tramvai/core';
|
|
2
2
|
|
|
3
|
-
export const {{ camelCase name }}Action =
|
|
3
|
+
export const {{ camelCase name }}Action = declareAction({
|
|
4
4
|
name: '{{ dashCase name }}-action',
|
|
5
|
-
fn
|
|
6
|
-
return
|
|
5
|
+
fn(payload) {
|
|
6
|
+
return this.dispatch({ type: 'FAKE_ACTION', payload });
|
|
7
7
|
},
|
|
8
8
|
conditions: {},
|
|
9
9
|
});
|
|
@@ -2,6 +2,7 @@ import execa from 'execa';
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
|
|
4
4
|
export async function initializationGit(localDir) {
|
|
5
|
-
console.log(chalk.blue('[
|
|
6
|
-
|
|
5
|
+
console.log(`${chalk.blue('[GIT]')} Initializing git`);
|
|
6
|
+
|
|
7
|
+
await execa('git', ['init'], { cwd: localDir, stdio: 'inherit' });
|
|
7
8
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { Options } from 'execa';
|
|
1
2
|
import execa from 'execa';
|
|
2
3
|
import chalk from 'chalk';
|
|
3
|
-
import ora from 'ora';
|
|
4
4
|
import type { PackageManagers } from '../questions/packageManager';
|
|
5
5
|
import type { TestingFrameworks } from '../questions/testingFramework';
|
|
6
6
|
import type { Type } from '../questions/type';
|
|
@@ -92,23 +92,30 @@ export async function installDependencies({
|
|
|
92
92
|
packageManager: PackageManagers;
|
|
93
93
|
testingFramework: TestingFrameworks;
|
|
94
94
|
}) {
|
|
95
|
-
const spinner = ora({
|
|
96
|
-
prefixText: `${chalk.blue('[START]')} Install dependencies`,
|
|
97
|
-
}).start();
|
|
98
|
-
|
|
99
95
|
const installCommands = packagesInstallCommands[packageManager];
|
|
100
|
-
const options
|
|
96
|
+
const options: Options = {
|
|
97
|
+
cwd: localDir,
|
|
98
|
+
env: {
|
|
99
|
+
SKIP_TRAMVAI_MIGRATIONS: 'true',
|
|
100
|
+
},
|
|
101
|
+
stdio: 'inherit',
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
console.log(`${chalk.blue('[DEPENDENCIES]')} Installing app dependencies`);
|
|
101
105
|
|
|
102
106
|
await execa(packageManager, [...installCommands.deps, ...DEPS[type].dependencies], options);
|
|
107
|
+
|
|
108
|
+
console.log(`${chalk.blue('[DEPENDENCIES]')} Installing dev dependencies`);
|
|
109
|
+
|
|
103
110
|
await execa(packageManager, [...installCommands.devDeps, ...devDependencies], options);
|
|
104
111
|
|
|
105
112
|
if (testingFramework === 'jest') {
|
|
113
|
+
console.log(`${chalk.blue('[DEPENDENCIES]')} Installing jest dependencies`);
|
|
114
|
+
|
|
106
115
|
await execa(
|
|
107
116
|
packageManager,
|
|
108
117
|
[...installCommands.devDeps, ...DEPS[type].jestDevDependencies],
|
|
109
118
|
options
|
|
110
119
|
);
|
|
111
120
|
}
|
|
112
|
-
|
|
113
|
-
spinner.stop();
|
|
114
121
|
}
|
|
@@ -2,6 +2,6 @@ import chalk from 'chalk';
|
|
|
2
2
|
import { applyTemplate } from '../utils/applyTemplate';
|
|
3
3
|
|
|
4
4
|
export async function renderTemplate(templateDir: string, projectDir: string, templateData) {
|
|
5
|
-
console.log(chalk.blue('[
|
|
5
|
+
console.log(chalk.blue('[TEMPLATE]'), 'Copying files');
|
|
6
6
|
return applyTemplate(templateDir, projectDir, templateData);
|
|
7
7
|
}
|
|
@@ -125,7 +125,11 @@ export function applyTemplate(
|
|
|
125
125
|
let warnings = 0;
|
|
126
126
|
templateFiles.forEach((templateFile) => {
|
|
127
127
|
if (processFileFromTemplate(templateFile, templateDir, projectDir, templateData)) {
|
|
128
|
-
console.log(
|
|
128
|
+
console.log(
|
|
129
|
+
chalk.blue('[TEMPLATE]'),
|
|
130
|
+
chalk.green('CREATE'),
|
|
131
|
+
transformOutputPath(replaceHbs(templateFile))
|
|
132
|
+
);
|
|
129
133
|
++processed;
|
|
130
134
|
} else {
|
|
131
135
|
++warnings;
|
|
@@ -98,6 +98,12 @@ export class StartCommand extends CLICommand<Params> {
|
|
|
98
98
|
description:
|
|
99
99
|
'Specify the names of the bundles that need to be collected, other bundles will not be collected and their request will fail with an error',
|
|
100
100
|
},
|
|
101
|
+
{
|
|
102
|
+
name: '--fileCache',
|
|
103
|
+
value: '[fileCache]',
|
|
104
|
+
transformer: (value) => value !== 'false',
|
|
105
|
+
description: 'Enable/disable persistent file cache for used cli builder',
|
|
106
|
+
},
|
|
101
107
|
];
|
|
102
108
|
|
|
103
109
|
alias = 's';
|
|
@@ -72,6 +72,12 @@ export class StartProdCommand extends CLICommand<Params> {
|
|
|
72
72
|
value: '[showConfig]',
|
|
73
73
|
description: 'Show config with which cli was launched',
|
|
74
74
|
},
|
|
75
|
+
{
|
|
76
|
+
name: '--fileCache',
|
|
77
|
+
value: '[fileCache]',
|
|
78
|
+
transformer: (value) => value !== 'false',
|
|
79
|
+
description: 'Enable/disable persistent file cache for used cli builder',
|
|
80
|
+
},
|
|
75
81
|
];
|
|
76
82
|
|
|
77
83
|
alias = 'sp';
|
|
@@ -40,6 +40,12 @@ export class StaticCommand extends CLICommand<Params> {
|
|
|
40
40
|
transformer: (value: string) => value.split(','),
|
|
41
41
|
description: 'Specify the comma separated paths list for static HTML generation',
|
|
42
42
|
},
|
|
43
|
+
{
|
|
44
|
+
name: '--fileCache',
|
|
45
|
+
value: '[fileCache]',
|
|
46
|
+
transformer: (value) => value !== 'false',
|
|
47
|
+
description: 'Enable/disable persistent file cache for used cli builder',
|
|
48
|
+
},
|
|
43
49
|
];
|
|
44
50
|
|
|
45
51
|
alias = 'st';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { getLatestPackageVersion } from '../../utils/commands/dependencies/getLatestPackageVersion';
|
|
2
|
+
import { getPackageInfo } from '../../utils/commands/dependencies/getPackageInfo';
|
|
3
|
+
|
|
4
|
+
// map of packages that is not in unified versioning
|
|
5
|
+
// but we still want to update it
|
|
6
|
+
// actual version to update will be calculated from the some of the @tramvai/module
|
|
7
|
+
const DEPENDANT_LIBS_MAP = new Map([
|
|
8
|
+
['@tinkoff/logger', '@tramvai/module-log'],
|
|
9
|
+
['@tinkoff/dippy', '@tramvai/core'],
|
|
10
|
+
['@tinkoff/router', '@tramvai/module-router'],
|
|
11
|
+
['@tinkoff/url', '@tramvai/module-common'],
|
|
12
|
+
['@tinkoff/errors', '@tramvai/module-common'],
|
|
13
|
+
['@tinkoff/roles', '@tramvai/module-authenticate'],
|
|
14
|
+
['@tinkoff/pubsub', '@tramvai/module-common'],
|
|
15
|
+
['@tinkoff/hook-runner', '@tramvai/module-common'],
|
|
16
|
+
['@tinkoff/htmlpagebuilder', '@tramvai/module-render'],
|
|
17
|
+
['@tinkoff/browser-timings', '@tramvai/module-metrics'],
|
|
18
|
+
['@tinkoff/meta-tags-generate', '@tramvai/module-render'],
|
|
19
|
+
['@tinkoff/pack-polyfills', ''],
|
|
20
|
+
['@tinkoff/browserslist-config', '@tramvai/cli'],
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
export const isDependantLib = (name: string) => {
|
|
24
|
+
return DEPENDANT_LIBS_MAP.has(name);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const getLibPackageVersion = async (
|
|
28
|
+
name: string,
|
|
29
|
+
unifiedVersion: string
|
|
30
|
+
): Promise<string | undefined> => {
|
|
31
|
+
const unifiedModule = DEPENDANT_LIBS_MAP.get(name);
|
|
32
|
+
|
|
33
|
+
if (!unifiedModule) {
|
|
34
|
+
return getLatestPackageVersion(name);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const deps = await getPackageInfo(`${unifiedModule}@${unifiedVersion}`, 'dependencies');
|
|
38
|
+
|
|
39
|
+
if (!deps[name]) {
|
|
40
|
+
console.warn(
|
|
41
|
+
`⚠️ cannot resolve proper version for the "${name}" package.
|
|
42
|
+
You have to update this package by yourself.`
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return deps[name];
|
|
49
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { updatePackageJson } from './updatePackageJson';
|
|
2
|
+
|
|
3
|
+
const LATEST_TRAMVAI_VERSION = '1.115.6';
|
|
4
|
+
const LATEST_LIB_VERSION = '0.8.23';
|
|
5
|
+
|
|
6
|
+
let mockPackageJson: Record<string, any>;
|
|
7
|
+
const mockFsWrite = jest.fn();
|
|
8
|
+
const mockPackageInfoDependencies = jest.fn<Record<string, string | undefined>, [string]>();
|
|
9
|
+
|
|
10
|
+
jest.mock('../../utils/commands/dependencies/packageHasVersion', () => ({
|
|
11
|
+
packageHasVersion: () => true,
|
|
12
|
+
}));
|
|
13
|
+
jest.mock('../../utils/commands/dependencies/getLatestPackageVersion', () => ({
|
|
14
|
+
getLatestPackageVersion: (dep: string) => {
|
|
15
|
+
if (dep.startsWith('@tramvai')) {
|
|
16
|
+
return LATEST_TRAMVAI_VERSION;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return LATEST_LIB_VERSION;
|
|
20
|
+
},
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
jest.mock('../../utils/commands/dependencies/getPackageInfo', () => ({
|
|
24
|
+
getPackageInfo: (packageName: string, field?: string) => {
|
|
25
|
+
if (field === 'dependencies') {
|
|
26
|
+
return mockPackageInfoDependencies(packageName);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
jest.mock('fs', () => ({
|
|
32
|
+
readFileSync: () => JSON.stringify(mockPackageJson),
|
|
33
|
+
writeFileSync: (...args: string[]) => mockFsWrite(...args),
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
beforeEach(() => {
|
|
37
|
+
mockFsWrite.mockClear();
|
|
38
|
+
mockPackageInfoDependencies.mockClear();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should update tramvai deps to latest versions', async () => {
|
|
42
|
+
mockPackageJson = {
|
|
43
|
+
dependencies: {
|
|
44
|
+
'@tramvai/core': '1.93.2',
|
|
45
|
+
'@tramvai/module-common': '1.93.2',
|
|
46
|
+
'@tinkoff/router': '^0.2.3',
|
|
47
|
+
'@tinkoff/url': '0.3.2',
|
|
48
|
+
},
|
|
49
|
+
devDependencies: {
|
|
50
|
+
'@tramvai/cli': '1.93.2',
|
|
51
|
+
},
|
|
52
|
+
peerDependencies: {
|
|
53
|
+
'@tinkoff/dippy': '0.7.10',
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
mockPackageInfoDependencies.mockImplementation((dep) => {
|
|
58
|
+
switch (dep) {
|
|
59
|
+
case '@tramvai/core@1.115.6':
|
|
60
|
+
return { '@tinkoff/dippy': '0.7.44', '@tinkoff/utils': '^2.1.0' };
|
|
61
|
+
case '@tramvai/module-common@1.115.6':
|
|
62
|
+
return {
|
|
63
|
+
'@tinkoff/error': '0.6.1',
|
|
64
|
+
'@tinkoff/url': '0.4.1',
|
|
65
|
+
};
|
|
66
|
+
case '@tramvai/cli@1.115.6':
|
|
67
|
+
return {};
|
|
68
|
+
case '@tramvai/module-router@1.115.6':
|
|
69
|
+
return {
|
|
70
|
+
'@tinkoff/router': '0.4.3',
|
|
71
|
+
'@tinkoff/url': '0.4.1',
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {};
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
await updatePackageJson(LATEST_TRAMVAI_VERSION);
|
|
79
|
+
|
|
80
|
+
expect(mockFsWrite.mock.calls[0]).toMatchInlineSnapshot(`
|
|
81
|
+
Array [
|
|
82
|
+
"package.json",
|
|
83
|
+
"{
|
|
84
|
+
\\"dependencies\\": {
|
|
85
|
+
\\"@tramvai/core\\": \\"1.115.6\\",
|
|
86
|
+
\\"@tramvai/module-common\\": \\"1.115.6\\",
|
|
87
|
+
\\"@tinkoff/router\\": \\"0.4.3\\",
|
|
88
|
+
\\"@tinkoff/url\\": \\"0.4.1\\"
|
|
89
|
+
},
|
|
90
|
+
\\"devDependencies\\": {
|
|
91
|
+
\\"@tramvai/cli\\": \\"1.115.6\\"
|
|
92
|
+
},
|
|
93
|
+
\\"peerDependencies\\": {
|
|
94
|
+
\\"@tinkoff/dippy\\": \\"0.7.44\\"
|
|
95
|
+
}
|
|
96
|
+
}",
|
|
97
|
+
]
|
|
98
|
+
`);
|
|
99
|
+
});
|
|
@@ -1,29 +1,11 @@
|
|
|
1
1
|
import { parse, minVersion } from 'semver';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import pMap from 'p-map';
|
|
4
|
-
import { getLatestPackageVersion } from '../../utils/commands/dependencies/getLatestPackageVersion';
|
|
5
4
|
import { packageHasVersion } from '../../utils/commands/dependencies/packageHasVersion';
|
|
5
|
+
import { getLibPackageVersion, isDependantLib } from './dependantLibs';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const packagesToUpdate = [
|
|
10
|
-
'@tinkoff/logger',
|
|
11
|
-
'@tinkoff/dippy',
|
|
12
|
-
'@tinkoff/router',
|
|
13
|
-
'@tinkoff/url',
|
|
14
|
-
'@tinkoff/errors',
|
|
15
|
-
'@tinkoff/roles',
|
|
16
|
-
'@tinkoff/pubsub',
|
|
17
|
-
'@tinkoff/hook-runner',
|
|
18
|
-
'@tinkoff/htmlpagebuilder',
|
|
19
|
-
'@tinkoff/browser-timings',
|
|
20
|
-
'@tinkoff/meta-tags-generate',
|
|
21
|
-
'@tinkoff/pack-polyfills',
|
|
22
|
-
'@tinkoff/browserslist-config',
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
const shouldUpdateDependency = (name: string) => {
|
|
26
|
-
return name.startsWith('@tramvai') || packagesToUpdate.includes(name);
|
|
7
|
+
const isUnifiedVersion = (name: string) => {
|
|
8
|
+
return name.startsWith('@tramvai');
|
|
27
9
|
};
|
|
28
10
|
|
|
29
11
|
const getVersionFromDep = (dep) => parse(dep)?.version || minVersion(dep)?.version;
|
|
@@ -35,11 +17,11 @@ const updateEntry = async (
|
|
|
35
17
|
) => {
|
|
36
18
|
let nextVersion: string;
|
|
37
19
|
|
|
38
|
-
if (dep
|
|
20
|
+
if (isUnifiedVersion(dep) && getVersionFromDep(deps[dep]) === currentVersion) {
|
|
39
21
|
nextVersion = version;
|
|
40
|
-
} else if (
|
|
41
|
-
const
|
|
42
|
-
nextVersion =
|
|
22
|
+
} else if (isDependantLib(dep)) {
|
|
23
|
+
const libVersion = await getLibPackageVersion(dep, version);
|
|
24
|
+
nextVersion = libVersion;
|
|
43
25
|
}
|
|
44
26
|
|
|
45
27
|
if (nextVersion) {
|
|
@@ -3,7 +3,7 @@ import prop from '@tinkoff/utils/object/prop';
|
|
|
3
3
|
import { resolve } from 'path';
|
|
4
4
|
import type { ProjectType, BuildType } from '../typings/projectType';
|
|
5
5
|
import type { Env } from '../typings/Env';
|
|
6
|
-
import type { ConfigEntry
|
|
6
|
+
import type { ConfigEntry } from '../typings/configEntry/common';
|
|
7
7
|
import { validate } from './validate';
|
|
8
8
|
import moduleVersion from '../utils/moduleVersion';
|
|
9
9
|
import { packageVersion } from '../utils/packageVersion';
|
|
@@ -32,6 +32,7 @@ export interface Settings<E extends Env> {
|
|
|
32
32
|
showConfig?: boolean;
|
|
33
33
|
onlyBundles?: string[];
|
|
34
34
|
disableProdOptimization?: boolean;
|
|
35
|
+
fileCache?: boolean;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
const getOption = <T>(optionName: string, cfgs: any[], dflt?: T): T => {
|
|
@@ -108,6 +109,8 @@ export class ConfigManager<T extends ConfigEntry = ConfigEntry, E extends Env =
|
|
|
108
109
|
|
|
109
110
|
public target: Target;
|
|
110
111
|
|
|
112
|
+
public fileCache: boolean;
|
|
113
|
+
|
|
111
114
|
public experiments: T['commands'][E extends 'development'
|
|
112
115
|
? 'serve'
|
|
113
116
|
: 'build']['configurations']['experiments'];
|
|
@@ -120,7 +123,7 @@ export class ConfigManager<T extends ConfigEntry = ConfigEntry, E extends Env =
|
|
|
120
123
|
this.type = configEntry.type;
|
|
121
124
|
this.root = configEntry.root;
|
|
122
125
|
this.build = configEntry.commands.build || {};
|
|
123
|
-
this.serve = configEntry.commands.serve ||
|
|
126
|
+
this.serve = configEntry.commands.serve || {};
|
|
124
127
|
|
|
125
128
|
this.settings = settings;
|
|
126
129
|
this.env = settings.env || ('development' as E);
|
|
@@ -156,7 +159,7 @@ export class ConfigManager<T extends ConfigEntry = ConfigEntry, E extends Env =
|
|
|
156
159
|
settings,
|
|
157
160
|
this.env === 'development' ? this.serve.configurations : this.build.configurations,
|
|
158
161
|
],
|
|
159
|
-
|
|
162
|
+
true
|
|
160
163
|
);
|
|
161
164
|
this.dedupe = this.build.configurations?.dedupe;
|
|
162
165
|
this.dedupeIgnore = this.build.configurations?.dedupeIgnore?.map(
|
|
@@ -168,6 +171,9 @@ export class ConfigManager<T extends ConfigEntry = ConfigEntry, E extends Env =
|
|
|
168
171
|
this.disableProdOptimization = settings.disableProdOptimization ?? false;
|
|
169
172
|
this.onlyBundles = settings.onlyBundles;
|
|
170
173
|
this.target = this.resolveTarget();
|
|
174
|
+
// according to measures fileCache in webpack doesn't affect
|
|
175
|
+
// performance much so enable it by default as it always was before
|
|
176
|
+
this.fileCache = settings.fileCache ?? true;
|
|
171
177
|
this.experiments =
|
|
172
178
|
(this.env === 'development'
|
|
173
179
|
? this.serve.configurations?.experiments
|
package/src/external/pages.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
default?: any;
|
|
3
|
-
}
|
|
1
|
+
import type { LazyComponentWrapper, PageComponent } from '@tramvai/react';
|
|
4
2
|
|
|
5
3
|
// eslint-disable-next-line import/no-default-export
|
|
6
4
|
export default {
|
|
7
5
|
routes: {},
|
|
8
6
|
pages: {},
|
|
9
7
|
} as {
|
|
10
|
-
routes: Record<string,
|
|
11
|
-
pages: Record<string,
|
|
8
|
+
routes: Record<string, LazyComponentWrapper<PageComponent>>;
|
|
9
|
+
pages: Record<string, LazyComponentWrapper<PageComponent>>;
|
|
12
10
|
};
|
|
@@ -34,6 +34,24 @@ import { createToken } from '@tramvai/core';
|
|
|
34
34
|
export var TOKEN = /*#__PURE__*/ createToken('token');
|
|
35
35
|
|
|
36
36
|
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
exports[`create-token-pure do not annotate more again: do not annotate more again 1`] = `
|
|
40
|
+
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
// eslint-disable-next-line import/no-unresolved
|
|
43
|
+
import { createToken } from '@tinkoff/dippy';
|
|
44
|
+
|
|
45
|
+
export const TOKEN = /* #__PURE__*/ createToken('token');
|
|
46
|
+
|
|
47
|
+
↓ ↓ ↓ ↓ ↓ ↓
|
|
48
|
+
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
// eslint-disable-next-line import/no-unresolved
|
|
51
|
+
import { createToken } from '@tinkoff/dippy';
|
|
52
|
+
export var TOKEN = /* #__PURE__*/ createToken('token');
|
|
53
|
+
|
|
54
|
+
|
|
37
55
|
`;
|
|
38
56
|
|
|
39
57
|
exports[`create-token-pure do nothing: do nothing 1`] = `
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import annotateAsPure from '@babel/helper-annotate-as-pure';
|
|
2
2
|
import type { Plugin } from './types.h';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
interface InnerState {
|
|
5
|
+
hasCreateToken: boolean;
|
|
6
|
+
}
|
|
6
7
|
|
|
8
|
+
export const createTokenPurePlugin: Plugin<InnerState> = ({ types: t }) => {
|
|
7
9
|
return {
|
|
10
|
+
pre() {
|
|
11
|
+
this.hasCreateToken = false;
|
|
12
|
+
},
|
|
8
13
|
visitor: {
|
|
9
14
|
ImportDeclaration(path) {
|
|
10
15
|
const { node } = path;
|
|
11
16
|
const sourceValue = node.source.value;
|
|
12
17
|
|
|
13
18
|
if (sourceValue === '@tramvai/core' || sourceValue === '@tinkoff/dippy') {
|
|
14
|
-
hasCreateToken = node.specifiers.some(
|
|
19
|
+
this.hasCreateToken = node.specifiers.some(
|
|
15
20
|
(s) => s.type === 'ImportSpecifier' && s.local?.name === 'createToken'
|
|
16
21
|
);
|
|
17
22
|
}
|
|
@@ -19,7 +24,7 @@ export const createTokenPurePlugin: Plugin = ({ types: t }) => {
|
|
|
19
24
|
CallExpression(path) {
|
|
20
25
|
const { node } = path;
|
|
21
26
|
|
|
22
|
-
if (!hasCreateToken) {
|
|
27
|
+
if (!this.hasCreateToken) {
|
|
23
28
|
return;
|
|
24
29
|
}
|
|
25
30
|
|
|
@@ -22,9 +22,7 @@ import { configToEnv } from '../../blocks/configToEnv';
|
|
|
22
22
|
export default (configManager: ConfigManager<ApplicationConfigEntry>) => (config: Config) => {
|
|
23
23
|
const {
|
|
24
24
|
options: { polyfill = '' } = {},
|
|
25
|
-
configurations: {
|
|
26
|
-
experiments: { fileSystemPages },
|
|
27
|
-
},
|
|
25
|
+
configurations: { fileSystemPages },
|
|
28
26
|
} = configManager.build;
|
|
29
27
|
|
|
30
28
|
config.name('client');
|
|
@@ -22,9 +22,7 @@ import { extractCssPluginFactory } from '../../blocks/extractCssPlugin';
|
|
|
22
22
|
export default (configManager: ConfigManager<ApplicationConfigEntry>) => (config: Config) => {
|
|
23
23
|
const {
|
|
24
24
|
options: { server = '', outputServer = '' } = {},
|
|
25
|
-
configurations: {
|
|
26
|
-
experiments: { fileSystemPages },
|
|
27
|
-
},
|
|
25
|
+
configurations: { fileSystemPages },
|
|
28
26
|
} = configManager.build;
|
|
29
27
|
|
|
30
28
|
config.name('server');
|
|
@@ -4,7 +4,7 @@ import type { ConfigEntry } from '../../../typings/configEntry/common';
|
|
|
4
4
|
import { shouldUseReactRoot } from '../../../utils/shouldUseReactRoot';
|
|
5
5
|
|
|
6
6
|
export const configToEnv = (configManager: ConfigManager<ConfigEntry>) => (config: Config) => {
|
|
7
|
-
const { fileSystemPages } = configManager.build.configurations
|
|
7
|
+
const { fileSystemPages } = configManager.build.configurations;
|
|
8
8
|
|
|
9
9
|
config.plugin('define').tap((args) => [
|
|
10
10
|
{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import path from 'path';
|
|
1
2
|
import type Config from 'webpack-chain';
|
|
2
3
|
import SparkMD5 from 'spark-md5';
|
|
3
4
|
import type { ConfigManager } from '../../../config/configManager';
|
|
@@ -33,9 +34,11 @@ export const filesClientWebackRulesFactory = (configManager: ConfigManager) => (
|
|
|
33
34
|
});
|
|
34
35
|
|
|
35
36
|
config.module
|
|
36
|
-
.rule('image')
|
|
37
|
+
.rule('tramvai-image')
|
|
37
38
|
.test(/\.(png|jpe?g|gif|webp)$/)
|
|
38
|
-
.
|
|
39
|
+
.use('file')
|
|
40
|
+
.loader(path.resolve(__dirname, '../loaders/image-loader'))
|
|
41
|
+
.end();
|
|
39
42
|
|
|
40
43
|
config.module
|
|
41
44
|
.rule('video')
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import path from 'path';
|
|
1
2
|
import type Config from 'webpack-chain';
|
|
2
3
|
import type { ConfigManager } from '../../../config/configManager';
|
|
3
4
|
|
|
@@ -28,12 +29,14 @@ export default (configManager: ConfigManager) => (config: Config) => {
|
|
|
28
29
|
});
|
|
29
30
|
|
|
30
31
|
config.module
|
|
31
|
-
.rule('image')
|
|
32
|
+
.rule('tramvai-image')
|
|
32
33
|
.test(/\.(png|jpe?g|gif|webp)$/)
|
|
33
|
-
.
|
|
34
|
-
.
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
.use('file')
|
|
35
|
+
.loader(path.resolve(__dirname, '../loaders/image-loader'))
|
|
36
|
+
.options({
|
|
37
|
+
emitFile: false,
|
|
38
|
+
})
|
|
39
|
+
.end();
|
|
37
40
|
|
|
38
41
|
config.module
|
|
39
42
|
.rule('video')
|
|
@@ -6,7 +6,7 @@ import type { ApplicationConfigEntry } from '../../../typings/configEntry/applic
|
|
|
6
6
|
export const pagesResolve = (configManager: ConfigManager<ApplicationConfigEntry>) => (
|
|
7
7
|
config: Config
|
|
8
8
|
) => {
|
|
9
|
-
const { fileSystemPages } = configManager.build.configurations
|
|
9
|
+
const { fileSystemPages } = configManager.build.configurations;
|
|
10
10
|
|
|
11
11
|
config.module
|
|
12
12
|
.rule('file-system-pages')
|