@servicetitan/startup 36.1.2-canary.5 → 36.1.2-canary.6
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/dist/cli/commands/clean.d.ts.map +1 -1
- package/dist/cli/commands/clean.js +5 -5
- package/dist/cli/commands/clean.js.map +1 -1
- package/dist/cli/commands/review/rules/require-npmrc.d.ts +3 -3
- package/dist/cli/commands/review/rules/require-npmrc.d.ts.map +1 -1
- package/dist/cli/commands/review/rules/require-npmrc.js +20 -9
- package/dist/cli/commands/review/rules/require-npmrc.js.map +1 -1
- package/dist/cypress/config/webpack-config.js +1 -0
- package/dist/cypress/config/webpack-config.js.map +1 -1
- package/dist/storybook-config/webpack-final.d.ts.map +1 -1
- package/dist/storybook-config/webpack-final.js +6 -0
- package/dist/storybook-config/webpack-final.js.map +1 -1
- package/dist/utils/get-default-excludes.d.ts +14 -0
- package/dist/utils/get-default-excludes.d.ts.map +1 -0
- package/dist/utils/get-default-excludes.js +22 -0
- package/dist/utils/get-default-excludes.js.map +1 -0
- package/dist/webpack/configs/constants.d.ts +2 -0
- package/dist/webpack/configs/constants.d.ts.map +1 -0
- package/dist/webpack/configs/constants.js +13 -0
- package/dist/webpack/configs/constants.js.map +1 -0
- package/package.json +17 -17
- package/src/cli/commands/clean.ts +5 -10
- package/src/cli/commands/review/rules/__tests__/require-npmrc.test.ts +75 -39
- package/src/cli/commands/review/rules/require-npmrc.ts +29 -11
- package/src/cypress/config/__tests__/webpack-config.test.ts +9 -0
- package/src/cypress/config/webpack-config.ts +1 -0
- package/src/scripts/generate-bin-wrappers.js +2 -9
- package/src/storybook-config/__tests__/webpack-final.test.ts +25 -0
- package/src/storybook-config/webpack-final.ts +4 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/clean.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAYlC,qBAAa,KAAM,SAAQ,OAAO,CAAC,OAAO,KAAK,CAAC;IAEtC,OAAO;
|
|
1
|
+
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/clean.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAYlC,qBAAa,KAAM,SAAQ,OAAO,CAAC,OAAO,KAAK,CAAC;IAEtC,OAAO;YAeC,UAAU;IASxB,OAAO,CAAC,mBAAmB;YAOb,aAAa;IAY3B,OAAO,CAAC,wBAAwB;CASnC"}
|
|
@@ -42,10 +42,9 @@ var CleanProcesses = /*#__PURE__*/ function(CleanProcesses) {
|
|
|
42
42
|
class Clean extends _types.Command {
|
|
43
43
|
async execute() {
|
|
44
44
|
const processTree = new _processtree.ProcessTree();
|
|
45
|
-
|
|
46
|
-
processTree.add(
|
|
47
|
-
processTree.add(
|
|
48
|
-
processTree.add(3, ()=>Promise.resolve(this.clearPackageManagerCache(packageManager)));
|
|
45
|
+
processTree.add(4, ()=>this.runCommand('nx reset'));
|
|
46
|
+
processTree.add(1, ()=>this.runCommand('jest --clearCache'));
|
|
47
|
+
processTree.add(3, ()=>Promise.resolve(this.clearPackageManagerCache()));
|
|
49
48
|
processTree.add(2, ()=>this.clearNpxCache());
|
|
50
49
|
await processTree.run();
|
|
51
50
|
this.cleanGitWorkingTree();
|
|
@@ -77,8 +76,9 @@ class Clean extends _types.Command {
|
|
|
77
76
|
_utils.log.error(`Error clearing npx cache: ${error}`);
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
|
-
clearPackageManagerCache(
|
|
79
|
+
clearPackageManagerCache() {
|
|
81
80
|
try {
|
|
81
|
+
const packageManager = (0, _install.getPackageManager)();
|
|
82
82
|
_utils.log.info(`Clearing ${packageManager.command} cache`);
|
|
83
83
|
packageManager.clearCache();
|
|
84
84
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/commands/clean.ts"],"sourcesContent":["import { getPackageManager } from '@servicetitan/install';\nimport { exec as execAsync, execSync } from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { promisify } from 'node:util';\nimport { log, logErrors } from '../../utils';\nimport { ProcessTree } from '../utils/process-tree';\nimport type { entry } from './registry/clean';\nimport { Command } from './types';\n\nconst exec = promisify(execAsync);\n\nenum CleanProcesses {\n CleanGitWorkingTree,\n ClearJestCache,\n ClearNpxCache,\n ClearPackageManagerCache,\n ResetNx,\n}\n\nexport class Clean extends Command<typeof entry> {\n @logErrors\n async execute() {\n const processTree = new ProcessTree<typeof CleanProcesses>();\n\n
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/commands/clean.ts"],"sourcesContent":["import { getPackageManager } from '@servicetitan/install';\nimport { exec as execAsync, execSync } from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { promisify } from 'node:util';\nimport { log, logErrors } from '../../utils';\nimport { ProcessTree } from '../utils/process-tree';\nimport type { entry } from './registry/clean';\nimport { Command } from './types';\n\nconst exec = promisify(execAsync);\n\nenum CleanProcesses {\n CleanGitWorkingTree,\n ClearJestCache,\n ClearNpxCache,\n ClearPackageManagerCache,\n ResetNx,\n}\n\nexport class Clean extends Command<typeof entry> {\n @logErrors\n async execute() {\n const processTree = new ProcessTree<typeof CleanProcesses>();\n\n processTree.add(CleanProcesses.ResetNx, () => this.runCommand('nx reset'));\n processTree.add(CleanProcesses.ClearJestCache, () => this.runCommand('jest --clearCache'));\n processTree.add(CleanProcesses.ClearPackageManagerCache, () =>\n Promise.resolve(this.clearPackageManagerCache())\n );\n processTree.add(CleanProcesses.ClearNpxCache, () => this.clearNpxCache());\n\n await processTree.run();\n\n this.cleanGitWorkingTree();\n }\n\n private async runCommand(command: string) {\n try {\n log.info(`Running: ${command}`);\n await exec(command);\n } catch (error) {\n log.error(`Error running ${command}: ${error}`);\n }\n }\n\n private cleanGitWorkingTree() {\n // Use exec() to avoid error when startup dependencies are deleted while startup is running\n const command = 'git clean -fdX';\n log.info(`Running: ${command}`);\n exec(command);\n }\n\n private async clearNpxCache() {\n try {\n const npmCacheDir = execSync('npm config get cache').toString().trim();\n const npxCachePath = path.join(npmCacheDir, '_npx');\n\n log.info('Clearing npx cache');\n await fs.promises.rm(npxCachePath, { recursive: true, force: true });\n } catch (error) {\n log.error(`Error clearing npx cache: ${error}`);\n }\n }\n\n private clearPackageManagerCache() {\n try {\n const packageManager = getPackageManager();\n log.info(`Clearing ${packageManager.command} cache`);\n packageManager.clearCache();\n } catch (error) {\n log.error(`Error clearing package manager cache: ${error}`);\n }\n }\n}\n"],"names":["Clean","exec","promisify","execAsync","CleanProcesses","Command","execute","processTree","ProcessTree","add","runCommand","Promise","resolve","clearPackageManagerCache","clearNpxCache","run","cleanGitWorkingTree","command","log","info","error","npmCacheDir","execSync","toString","trim","npxCachePath","path","join","fs","promises","rm","recursive","force","packageManager","getPackageManager","clearCache"],"mappings":";;;;+BAoBaA;;;eAAAA;;;yBApBqB;mCACU;+DAC7B;iEACE;0BACS;uBACK;6BACH;uBAEJ;;;;;;;;;;;;;;;AAExB,MAAMC,OAAOC,IAAAA,mBAAS,EAACC,uBAAS;AAEhC,IAAA,AAAKC,wCAAAA;;;;;;WAAAA;EAAAA;AAQE,MAAMJ,cAAcK,cAAO;IAC9B,MACMC,UAAU;QACZ,MAAMC,cAAc,IAAIC,wBAAW;QAEnCD,YAAYE,GAAG,IAAyB,IAAM,IAAI,CAACC,UAAU,CAAC;QAC9DH,YAAYE,GAAG,IAAgC,IAAM,IAAI,CAACC,UAAU,CAAC;QACrEH,YAAYE,GAAG,IAA0C,IACrDE,QAAQC,OAAO,CAAC,IAAI,CAACC,wBAAwB;QAEjDN,YAAYE,GAAG,IAA+B,IAAM,IAAI,CAACK,aAAa;QAEtE,MAAMP,YAAYQ,GAAG;QAErB,IAAI,CAACC,mBAAmB;IAC5B;IAEA,MAAcN,WAAWO,OAAe,EAAE;QACtC,IAAI;YACAC,UAAG,CAACC,IAAI,CAAC,CAAC,SAAS,EAAEF,SAAS;YAC9B,MAAMhB,KAAKgB;QACf,EAAE,OAAOG,OAAO;YACZF,UAAG,CAACE,KAAK,CAAC,CAAC,cAAc,EAAEH,QAAQ,EAAE,EAAEG,OAAO;QAClD;IACJ;IAEQJ,sBAAsB;QAC1B,2FAA2F;QAC3F,MAAMC,UAAU;QAChBC,UAAG,CAACC,IAAI,CAAC,CAAC,SAAS,EAAEF,SAAS;QAC9BhB,KAAKgB;IACT;IAEA,MAAcH,gBAAgB;QAC1B,IAAI;YACA,MAAMO,cAAcC,IAAAA,2BAAQ,EAAC,wBAAwBC,QAAQ,GAAGC,IAAI;YACpE,MAAMC,eAAeC,iBAAI,CAACC,IAAI,CAACN,aAAa;YAE5CH,UAAG,CAACC,IAAI,CAAC;YACT,MAAMS,eAAE,CAACC,QAAQ,CAACC,EAAE,CAACL,cAAc;gBAAEM,WAAW;gBAAMC,OAAO;YAAK;QACtE,EAAE,OAAOZ,OAAO;YACZF,UAAG,CAACE,KAAK,CAAC,CAAC,0BAA0B,EAAEA,OAAO;QAClD;IACJ;IAEQP,2BAA2B;QAC/B,IAAI;YACA,MAAMoB,iBAAiBC,IAAAA,0BAAiB;YACxChB,UAAG,CAACC,IAAI,CAAC,CAAC,SAAS,EAAEc,eAAehB,OAAO,CAAC,MAAM,CAAC;YACnDgB,eAAeE,UAAU;QAC7B,EAAE,OAAOf,OAAO;YACZF,UAAG,CAACE,KAAK,CAAC,CAAC,sCAAsC,EAAEA,OAAO;QAC9D;IACJ;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PackageError, PackageRule } from '../types';
|
|
1
|
+
import { PackageError, PackageRule, Project } from '../types';
|
|
2
2
|
export declare class RequireNpmrc implements PackageRule {
|
|
3
3
|
get id(): string;
|
|
4
|
-
run(): PackageError
|
|
5
|
-
fix(): void;
|
|
4
|
+
run(project: Project): PackageError[];
|
|
5
|
+
fix(error: PackageError<string>): void;
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=require-npmrc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"require-npmrc.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/review/rules/require-npmrc.ts"],"names":[],"mappings":"AAEA,OAAO,EAA8B,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"require-npmrc.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/review/rules/require-npmrc.ts"],"names":[],"mappings":"AAEA,OAAO,EAA8B,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAW1F,qBAAa,YAAa,YAAW,WAAW;IAC5C,IAAI,EAAE,WAEL;IAED,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,EAAE;IAqBrC,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC;CAKlC"}
|
|
@@ -11,25 +11,36 @@ Object.defineProperty(exports, "RequireNpmrc", {
|
|
|
11
11
|
const _child_process = require("child_process");
|
|
12
12
|
const _utils = require("../../../../utils");
|
|
13
13
|
const _types = require("../types");
|
|
14
|
+
const REQUIRED_SETTINGS = [
|
|
15
|
+
{
|
|
16
|
+
key: 'legacy-peer-deps',
|
|
17
|
+
packageManager: 'npm',
|
|
18
|
+
severity: _types.ErrorSeverity.warning
|
|
19
|
+
}
|
|
20
|
+
];
|
|
14
21
|
class RequireNpmrc {
|
|
15
22
|
get id() {
|
|
16
23
|
return 'require-npmrc';
|
|
17
24
|
}
|
|
18
|
-
run() {
|
|
25
|
+
run(project) {
|
|
19
26
|
const stdout = (0, _child_process.execSync)('npm config list --json', {
|
|
20
27
|
encoding: 'utf8'
|
|
21
28
|
});
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
const config = JSON.parse(stdout);
|
|
30
|
+
function omitsRequiredSetting({ key, packageManager }) {
|
|
31
|
+
return config[key] !== true && (!packageManager || packageManager === project.packageManager.command);
|
|
32
|
+
}
|
|
33
|
+
return REQUIRED_SETTINGS.filter(omitsRequiredSetting).map(({ key, severity })=>({
|
|
24
34
|
id: this.id,
|
|
25
|
-
|
|
26
|
-
|
|
35
|
+
data: key,
|
|
36
|
+
location: '.npmrc',
|
|
37
|
+
message: `project does not contain .npmrc with ${key}=true`,
|
|
38
|
+
severity,
|
|
27
39
|
fixable: _types.FixCategory.isolated
|
|
28
|
-
};
|
|
29
|
-
}
|
|
40
|
+
}));
|
|
30
41
|
}
|
|
31
|
-
fix() {
|
|
32
|
-
const command =
|
|
42
|
+
fix(error) {
|
|
43
|
+
const command = `npm config set --location=project ${error.data}=true`;
|
|
33
44
|
_utils.log.debug(`review:${this.id}`, `Running ${command}`);
|
|
34
45
|
(0, _child_process.execSync)(command);
|
|
35
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/cli/commands/review/rules/require-npmrc.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport { log } from '../../../../utils';\nimport { ErrorSeverity, FixCategory, PackageError, PackageRule } from '../types';\n\nexport class RequireNpmrc implements PackageRule {\n get id() {\n return 'require-npmrc';\n }\n\n run(): PackageError
|
|
1
|
+
{"version":3,"sources":["../../../../../src/cli/commands/review/rules/require-npmrc.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport { log } from '../../../../utils';\nimport { ErrorSeverity, FixCategory, PackageError, PackageRule, Project } from '../types';\n\ninterface RequiresSetting {\n key: string;\n packageManager?: 'npm' | 'pnpm';\n severity?: ErrorSeverity;\n}\nconst REQUIRED_SETTINGS: RequiresSetting[] = [\n { key: 'legacy-peer-deps', packageManager: 'npm', severity: ErrorSeverity.warning },\n];\n\nexport class RequireNpmrc implements PackageRule {\n get id() {\n return 'require-npmrc';\n }\n\n run(project: Project): PackageError[] {\n const stdout = execSync('npm config list --json', { encoding: 'utf8' });\n const config = JSON.parse(stdout);\n\n function omitsRequiredSetting({ key, packageManager }: RequiresSetting) {\n return (\n config[key] !== true &&\n (!packageManager || packageManager === project.packageManager.command)\n );\n }\n\n return REQUIRED_SETTINGS.filter(omitsRequiredSetting).map(({ key, severity }) => ({\n id: this.id,\n data: key,\n location: '.npmrc',\n message: `project does not contain .npmrc with ${key}=true`,\n severity,\n fixable: FixCategory.isolated,\n }));\n }\n\n fix(error: PackageError<string>) {\n const command = `npm config set --location=project ${error.data}=true`;\n log.debug(`review:${this.id}`, `Running ${command}`);\n execSync(command);\n }\n}\n"],"names":["RequireNpmrc","REQUIRED_SETTINGS","key","packageManager","severity","ErrorSeverity","warning","id","run","project","stdout","execSync","encoding","config","JSON","parse","omitsRequiredSetting","command","filter","map","data","location","message","fixable","FixCategory","isolated","fix","error","log","debug"],"mappings":";;;;+BAaaA;;;eAAAA;;;+BAbY;uBACL;uBAC2D;AAO/E,MAAMC,oBAAuC;IACzC;QAAEC,KAAK;QAAoBC,gBAAgB;QAAOC,UAAUC,oBAAa,CAACC,OAAO;IAAC;CACrF;AAEM,MAAMN;IACT,IAAIO,KAAK;QACL,OAAO;IACX;IAEAC,IAAIC,OAAgB,EAAkB;QAClC,MAAMC,SAASC,IAAAA,uBAAQ,EAAC,0BAA0B;YAAEC,UAAU;QAAO;QACrE,MAAMC,SAASC,KAAKC,KAAK,CAACL;QAE1B,SAASM,qBAAqB,EAAEd,GAAG,EAAEC,cAAc,EAAmB;YAClE,OACIU,MAAM,CAACX,IAAI,KAAK,QACf,CAAA,CAACC,kBAAkBA,mBAAmBM,QAAQN,cAAc,CAACc,OAAO,AAAD;QAE5E;QAEA,OAAOhB,kBAAkBiB,MAAM,CAACF,sBAAsBG,GAAG,CAAC,CAAC,EAAEjB,GAAG,EAAEE,QAAQ,EAAE,GAAM,CAAA;gBAC9EG,IAAI,IAAI,CAACA,EAAE;gBACXa,MAAMlB;gBACNmB,UAAU;gBACVC,SAAS,CAAC,qCAAqC,EAAEpB,IAAI,KAAK,CAAC;gBAC3DE;gBACAmB,SAASC,kBAAW,CAACC,QAAQ;YACjC,CAAA;IACJ;IAEAC,IAAIC,KAA2B,EAAE;QAC7B,MAAMV,UAAU,CAAC,kCAAkC,EAAEU,MAAMP,IAAI,CAAC,KAAK,CAAC;QACtEQ,UAAG,CAACC,KAAK,CAAC,CAAC,OAAO,EAAE,IAAI,CAACtB,EAAE,EAAE,EAAE,CAAC,QAAQ,EAAEU,SAAS;QACnDN,IAAAA,uBAAQ,EAACM;IACb;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cypress/config/webpack-config.ts"],"sourcesContent":["import { inspect } from 'node:util';\nimport type { Configuration } from 'webpack';\nimport merge from 'webpack-merge';\nimport { getSwcOptions } from '../../cli/tasks';\nimport { TSConfig } from '../../cli/utils';\nimport { getTsConfigWithFallback, log } from '../../utils';\nimport { Context, Overrides, rulesConfig } from '../../webpack/configs';\n\nexport function webpackConfig(overrides?: Overrides): Configuration {\n const context = getContext();\n const rules = getRules(context, overrides ?? {});\n\n /* istanbul ignore next: debug only */\n log.debug('cypress-config:webpack-config', () => inspect({ rules }, { depth: null }));\n\n const config: Configuration = {\n module: {\n rules,\n },\n resolve: {\n extensions: ['.ts', '.tsx', '.js', '.jsx'],\n },\n };\n\n return merge(config, overrides?.configuration ?? {});\n}\n\nfunction getContext(): Context {\n return {\n destination: '',\n isProduction: false,\n name: '',\n packageData: {} as any,\n sharedDependencies: {},\n source: '',\n };\n}\n\nfunction getRules(context: Context, overrides: Overrides) {\n const { rules } = rulesConfig(context, overrides);\n\n return [getSwcLoaderRule(), ...rules];\n}\n\nfunction getSwcLoaderRule() {\n const tsConfig = new TSConfig(getTsConfigWithFallback());\n\n const swcOptions = getSwcOptions(tsConfig);\n\n return {\n test: /\\.tsx?$/,\n exclude: /node_modules/,\n use: {\n loader: 'swc-loader',\n options: swcOptions,\n },\n };\n}\n"],"names":["webpackConfig","overrides","context","getContext","rules","getRules","log","debug","inspect","depth","config","module","resolve","extensions","merge","configuration","destination","isProduction","name","packageData","sharedDependencies","source","rulesConfig","getSwcLoaderRule","tsConfig","TSConfig","getTsConfigWithFallback","swcOptions","getSwcOptions","test","exclude","use","loader","options"],"mappings":";;;;+BAQgBA;;;eAAAA;;;0BARQ;qEAEN;uBACY;uBACL;wBACoB;yBACG;;;;;;AAEzC,SAASA,cAAcC,SAAqB;;IAC/C,MAAMC,UAAUC;IAChB,MAAMC,QAAQC,SAASH,SAASD,sBAAAA,uBAAAA,YAAa,CAAC;IAE9C,oCAAoC,GACpCK,WAAG,CAACC,KAAK,CAAC,iCAAiC,IAAMC,IAAAA,iBAAO,EAAC;YAAEJ;QAAM,GAAG;YAAEK,OAAO;QAAK;IAElF,MAAMC,SAAwB;QAC1BC,QAAQ;YACJP;QACJ;QACAQ,SAAS;YACLC,YAAY;gBAAC;gBAAO;gBAAQ;gBAAO;aAAO;QAC9C;IACJ;IAEA,OAAOC,IAAAA,qBAAK,EAACJ,gBAAQT,sBAAAA,gCAAAA,UAAWc,aAAa,uCAAI,CAAC;AACtD;AAEA,SAASZ;IACL,OAAO;QACHa,aAAa;QACbC,cAAc;QACdC,MAAM;QACNC,aAAa,CAAC;QACdC,oBAAoB,CAAC;QACrBC,QAAQ;IACZ;AACJ;AAEA,
|
|
1
|
+
{"version":3,"sources":["../../../src/cypress/config/webpack-config.ts"],"sourcesContent":["import { inspect } from 'node:util';\nimport type { Configuration } from 'webpack';\nimport merge from 'webpack-merge';\nimport { getSwcOptions } from '../../cli/tasks';\nimport { TSConfig } from '../../cli/utils';\nimport { getTsConfigWithFallback, log } from '../../utils';\nimport { Context, Overrides, rulesConfig } from '../../webpack/configs';\n\nexport function webpackConfig(overrides?: Overrides): Configuration {\n const context = getContext();\n const rules = getRules(context, overrides ?? {});\n\n /* istanbul ignore next: debug only */\n log.debug('cypress-config:webpack-config', () => inspect({ rules }, { depth: null }));\n\n const config: Configuration = {\n module: {\n rules,\n },\n resolve: {\n extensions: ['.ts', '.tsx', '.js', '.jsx'],\n },\n };\n\n return merge(config, overrides?.configuration ?? {});\n}\n\nfunction getContext(): Context {\n return {\n codeCoverage: true,\n destination: '',\n isProduction: false,\n name: '',\n packageData: {} as any,\n sharedDependencies: {},\n source: '',\n };\n}\n\nfunction getRules(context: Context, overrides: Overrides) {\n const { rules } = rulesConfig(context, overrides);\n\n return [getSwcLoaderRule(), ...rules];\n}\n\nfunction getSwcLoaderRule() {\n const tsConfig = new TSConfig(getTsConfigWithFallback());\n\n const swcOptions = getSwcOptions(tsConfig);\n\n return {\n test: /\\.tsx?$/,\n exclude: /node_modules/,\n use: {\n loader: 'swc-loader',\n options: swcOptions,\n },\n };\n}\n"],"names":["webpackConfig","overrides","context","getContext","rules","getRules","log","debug","inspect","depth","config","module","resolve","extensions","merge","configuration","codeCoverage","destination","isProduction","name","packageData","sharedDependencies","source","rulesConfig","getSwcLoaderRule","tsConfig","TSConfig","getTsConfigWithFallback","swcOptions","getSwcOptions","test","exclude","use","loader","options"],"mappings":";;;;+BAQgBA;;;eAAAA;;;0BARQ;qEAEN;uBACY;uBACL;wBACoB;yBACG;;;;;;AAEzC,SAASA,cAAcC,SAAqB;;IAC/C,MAAMC,UAAUC;IAChB,MAAMC,QAAQC,SAASH,SAASD,sBAAAA,uBAAAA,YAAa,CAAC;IAE9C,oCAAoC,GACpCK,WAAG,CAACC,KAAK,CAAC,iCAAiC,IAAMC,IAAAA,iBAAO,EAAC;YAAEJ;QAAM,GAAG;YAAEK,OAAO;QAAK;IAElF,MAAMC,SAAwB;QAC1BC,QAAQ;YACJP;QACJ;QACAQ,SAAS;YACLC,YAAY;gBAAC;gBAAO;gBAAQ;gBAAO;aAAO;QAC9C;IACJ;IAEA,OAAOC,IAAAA,qBAAK,EAACJ,gBAAQT,sBAAAA,gCAAAA,UAAWc,aAAa,uCAAI,CAAC;AACtD;AAEA,SAASZ;IACL,OAAO;QACHa,cAAc;QACdC,aAAa;QACbC,cAAc;QACdC,MAAM;QACNC,aAAa,CAAC;QACdC,oBAAoB,CAAC;QACrBC,QAAQ;IACZ;AACJ;AAEA,SAASjB,SAASH,OAAgB,EAAED,SAAoB;IACpD,MAAM,EAAEG,KAAK,EAAE,GAAGmB,IAAAA,oBAAW,EAACrB,SAASD;IAEvC,OAAO;QAACuB;WAAuBpB;KAAM;AACzC;AAEA,SAASoB;IACL,MAAMC,WAAW,IAAIC,eAAQ,CAACC,IAAAA,+BAAuB;IAErD,MAAMC,aAAaC,IAAAA,oBAAa,EAACJ;IAEjC,OAAO;QACHK,MAAM;QACNC,SAAS;QACTC,KAAK;YACDC,QAAQ;YACRC,SAASN;QACb;IACJ;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack-final.d.ts","sourceRoot":"","sources":["../../src/storybook-config/webpack-final.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAW,SAAS,EAAe,MAAM,oBAAoB,CAAC;AAGrE,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,GAAE,SAAc,GAAG,aAAa,
|
|
1
|
+
{"version":3,"file":"webpack-final.d.ts","sourceRoot":"","sources":["../../src/storybook-config/webpack-final.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAW,SAAS,EAAe,MAAM,oBAAoB,CAAC;AAGrE,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,GAAE,SAAc,GAAG,aAAa,CAoB5F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/storybook-config/webpack-final.ts"],"sourcesContent":["import { inspect } from 'node:util';\nimport type { Configuration } from 'webpack';\nimport { log } from '../utils';\nimport { Context, Overrides, rulesConfig } from '../webpack/configs';\nimport { miniCssExtractPlugin } from '../webpack/configs/plugins';\n\nexport function webpackFinal(config: Configuration, overrides: Overrides = {}): Configuration {\n const context = getContext(config);\n const rules = getRules(context, overrides);\n const plugins = getPlugins(context, overrides);\n\n /* istanbul ignore next: debug only */\n log.debug('storybook-config:webpack-final', () => inspect({ rules, plugins }, { depth: null }));\n\n return {\n ...config,\n module: {\n ...config.module,\n rules: [...transformDefaultRules(config.module?.rules), ...rules],\n },\n plugins: [...(config.plugins ?? []), ...plugins],\n };\n}\n\nfunction getContext(config: Configuration): Context {\n return {\n destination: '',\n isProduction: config.mode === 'production',\n name: '',\n packageData: {} as any,\n sharedDependencies: {},\n source: '',\n };\n}\n\nfunction getPlugins(context: Context, overrides: Overrides) {\n return [miniCssExtractPlugin(context, overrides)].filter(plugin => !!plugin);\n}\n\nfunction getRules(context: Context, overrides: Overrides) {\n const include = ['.module.css', '.module.less', '.less', '.module.scss', '.scss', '.svg'];\n const exclude = ['.css'];\n\n const { rules } = rulesConfig(context, overrides);\n\n return rules.filter(\n ({ test }) =>\n !(test instanceof RegExp) ||\n include.some(ext => test.exec(ext) && !exclude.some(ext => test.exec(ext)))\n );\n}\n\nfunction transformDefaultRules(rules: NonNullable<Configuration['module']>['rules'] = []) {\n const result = rules.map(rule => {\n if (rule && typeof rule === 'object' && rule.test instanceof RegExp) {\n if (rule.test.test('.css')) {\n return { ...rule, exclude: /\\.module.css$/ };\n }\n if (rule.test.test('.svg')) {\n return { ...rule, exclude: /\\.svg$/i };\n }\n }\n return rule;\n });\n\n /* istanbul ignore next: debug only */\n log.debug('storybook-config:transform-default-rules', () =>\n inspect({ result }, { depth: null })\n );\n\n return result;\n}\n"],"names":["webpackFinal","config","overrides","context","getContext","rules","getRules","plugins","getPlugins","log","debug","inspect","depth","module","transformDefaultRules","destination","isProduction","
|
|
1
|
+
{"version":3,"sources":["../../src/storybook-config/webpack-final.ts"],"sourcesContent":["import { inspect } from 'node:util';\nimport type { Configuration } from 'webpack';\nimport { log } from '../utils';\nimport { Context, Overrides, rulesConfig } from '../webpack/configs';\nimport { miniCssExtractPlugin } from '../webpack/configs/plugins';\n\nexport function webpackFinal(config: Configuration, overrides: Overrides = {}): Configuration {\n const context = getContext(config);\n const rules = getRules(context, overrides);\n const plugins = getPlugins(context, overrides);\n\n /* istanbul ignore next: debug only */\n log.debug('storybook-config:webpack-final', () => inspect({ rules, plugins }, { depth: null }));\n\n return {\n ...config,\n optimization: {\n ...config.optimization,\n ...(config.mode !== 'production' ? { sideEffects: false } : {}),\n },\n module: {\n ...config.module,\n rules: [...transformDefaultRules(config.module?.rules), ...rules],\n },\n plugins: [...(config.plugins ?? []), ...plugins],\n };\n}\n\nfunction getContext(config: Configuration): Context {\n return {\n destination: '',\n isProduction: config.mode === 'production',\n name: '',\n packageData: {} as any,\n sharedDependencies: {},\n source: '',\n };\n}\n\nfunction getPlugins(context: Context, overrides: Overrides) {\n return [miniCssExtractPlugin(context, overrides)].filter(plugin => !!plugin);\n}\n\nfunction getRules(context: Context, overrides: Overrides) {\n const include = ['.module.css', '.module.less', '.less', '.module.scss', '.scss', '.svg'];\n const exclude = ['.css'];\n\n const { rules } = rulesConfig(context, overrides);\n\n return rules.filter(\n ({ test }) =>\n !(test instanceof RegExp) ||\n include.some(ext => test.exec(ext) && !exclude.some(ext => test.exec(ext)))\n );\n}\n\nfunction transformDefaultRules(rules: NonNullable<Configuration['module']>['rules'] = []) {\n const result = rules.map(rule => {\n if (rule && typeof rule === 'object' && rule.test instanceof RegExp) {\n if (rule.test.test('.css')) {\n return { ...rule, exclude: /\\.module.css$/ };\n }\n if (rule.test.test('.svg')) {\n return { ...rule, exclude: /\\.svg$/i };\n }\n }\n return rule;\n });\n\n /* istanbul ignore next: debug only */\n log.debug('storybook-config:transform-default-rules', () =>\n inspect({ result }, { depth: null })\n );\n\n return result;\n}\n"],"names":["webpackFinal","config","overrides","context","getContext","rules","getRules","plugins","getPlugins","log","debug","inspect","depth","optimization","mode","sideEffects","module","transformDefaultRules","destination","isProduction","name","packageData","sharedDependencies","source","miniCssExtractPlugin","filter","plugin","include","exclude","rulesConfig","test","RegExp","some","ext","exec","result","map","rule"],"mappings":";;;;+BAMgBA;;;eAAAA;;;0BANQ;uBAEJ;yBAC4B;yBACX;AAE9B,SAASA,aAAaC,MAAqB,EAAEC,YAAuB,CAAC,CAAC;QAkBvDD;QAFuBA;IAfzC,MAAME,UAAUC,WAAWH;IAC3B,MAAMI,QAAQC,SAASH,SAASD;IAChC,MAAMK,UAAUC,WAAWL,SAASD;IAEpC,oCAAoC,GACpCO,UAAG,CAACC,KAAK,CAAC,kCAAkC,IAAMC,IAAAA,iBAAO,EAAC;YAAEN;YAAOE;QAAQ,GAAG;YAAEK,OAAO;QAAK;IAE5F,OAAO;QACH,GAAGX,MAAM;QACTY,cAAc;YACV,GAAGZ,OAAOY,YAAY;YACtB,GAAIZ,OAAOa,IAAI,KAAK,eAAe;gBAAEC,aAAa;YAAM,IAAI,CAAC,CAAC;QAClE;QACAC,QAAQ;YACJ,GAAGf,OAAOe,MAAM;YAChBX,OAAO;mBAAIY,uBAAsBhB,iBAAAA,OAAOe,MAAM,cAAbf,qCAAAA,eAAeI,KAAK;mBAAMA;aAAM;QACrE;QACAE,SAAS;gBAAKN,kBAAAA,OAAOM,OAAO,cAAdN,6BAAAA,kBAAkB,EAAE;eAAMM;SAAQ;IACpD;AACJ;AAEA,SAASH,WAAWH,MAAqB;IACrC,OAAO;QACHiB,aAAa;QACbC,cAAclB,OAAOa,IAAI,KAAK;QAC9BM,MAAM;QACNC,aAAa,CAAC;QACdC,oBAAoB,CAAC;QACrBC,QAAQ;IACZ;AACJ;AAEA,SAASf,WAAWL,OAAgB,EAAED,SAAoB;IACtD,OAAO;QAACsB,IAAAA,6BAAoB,EAACrB,SAASD;KAAW,CAACuB,MAAM,CAACC,CAAAA,SAAU,CAAC,CAACA;AACzE;AAEA,SAASpB,SAASH,OAAgB,EAAED,SAAoB;IACpD,MAAMyB,UAAU;QAAC;QAAe;QAAgB;QAAS;QAAgB;QAAS;KAAO;IACzF,MAAMC,UAAU;QAAC;KAAO;IAExB,MAAM,EAAEvB,KAAK,EAAE,GAAGwB,IAAAA,oBAAW,EAAC1B,SAASD;IAEvC,OAAOG,MAAMoB,MAAM,CACf,CAAC,EAAEK,IAAI,EAAE,GACL,CAAEA,CAAAA,gBAAgBC,MAAK,KACvBJ,QAAQK,IAAI,CAACC,CAAAA,MAAOH,KAAKI,IAAI,CAACD,QAAQ,CAACL,QAAQI,IAAI,CAACC,CAAAA,MAAOH,KAAKI,IAAI,CAACD;AAEjF;AAEA,SAAShB,sBAAsBZ,QAAuD,EAAE;IACpF,MAAM8B,SAAS9B,MAAM+B,GAAG,CAACC,CAAAA;QACrB,IAAIA,QAAQ,OAAOA,SAAS,YAAYA,KAAKP,IAAI,YAAYC,QAAQ;YACjE,IAAIM,KAAKP,IAAI,CAACA,IAAI,CAAC,SAAS;gBACxB,OAAO;oBAAE,GAAGO,IAAI;oBAAET,SAAS;gBAAgB;YAC/C;YACA,IAAIS,KAAKP,IAAI,CAACA,IAAI,CAAC,SAAS;gBACxB,OAAO;oBAAE,GAAGO,IAAI;oBAAET,SAAS;gBAAU;YACzC;QACJ;QACA,OAAOS;IACX;IAEA,oCAAoC,GACpC5B,UAAG,CAACC,KAAK,CAAC,4CAA4C,IAClDC,IAAAA,iBAAO,EAAC;YAAEwB;QAAO,GAAG;YAAEvB,OAAO;QAAK;IAGtC,OAAOuB;AACX"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns default exclusions applied to both test running and coverage
|
|
3
|
+
* collection in Jest and Vitest.
|
|
4
|
+
*
|
|
5
|
+
* Patterns use regex syntax (for Jest testPathIgnorePatterns /
|
|
6
|
+
* coveragePathIgnorePatterns) and double as substring matches in Vitest's
|
|
7
|
+
* micromatch-based exclude / coverage.exclude.
|
|
8
|
+
*
|
|
9
|
+
* Destination folders (compiled output dirs from each package's tsconfig
|
|
10
|
+
* outDir) are included so that dist/ files are excluded from tests and
|
|
11
|
+
* coverage across all runners.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getDefaultExcludes(): string[];
|
|
14
|
+
//# sourceMappingURL=get-default-excludes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-default-excludes.d.ts","sourceRoot":"","sources":["../../src/utils/get-default-excludes.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,CAE7C"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getDefaultExcludes", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getDefaultExcludes;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _getdestinationfolders = require("./get-destination-folders");
|
|
12
|
+
function getDefaultExcludes() {
|
|
13
|
+
return [
|
|
14
|
+
'__mocks__',
|
|
15
|
+
'\\.stories\\.',
|
|
16
|
+
'\\.yalc',
|
|
17
|
+
'\\.d\\.ts',
|
|
18
|
+
...(0, _getdestinationfolders.getDestinationFolders)()
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=get-default-excludes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/get-default-excludes.ts"],"sourcesContent":["import { getDestinationFolders } from './get-destination-folders';\n\n/**\n * Returns default exclusions applied to both test running and coverage\n * collection in Jest and Vitest.\n *\n * Patterns use regex syntax (for Jest testPathIgnorePatterns /\n * coveragePathIgnorePatterns) and double as substring matches in Vitest's\n * micromatch-based exclude / coverage.exclude.\n *\n * Destination folders (compiled output dirs from each package's tsconfig\n * outDir) are included so that dist/ files are excluded from tests and\n * coverage across all runners.\n */\nexport function getDefaultExcludes(): string[] {\n return ['__mocks__', '\\\\.stories\\\\.', '\\\\.yalc', '\\\\.d\\\\.ts', ...getDestinationFolders()];\n}\n"],"names":["getDefaultExcludes","getDestinationFolders"],"mappings":";;;;+BAcgBA;;;eAAAA;;;uCAdsB;AAc/B,SAASA;IACZ,OAAO;QAAC;QAAa;QAAiB;QAAW;WAAgBC,IAAAA,4CAAqB;KAAG;AAC7F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/webpack/configs/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,QAA0B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "JS_RULE_EXCLUDE", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return JS_RULE_EXCLUDE;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const JS_RULE_EXCLUDE = /(node_modules|\.yalc)/;
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/webpack/configs/constants.ts"],"sourcesContent":["export const JS_RULE_EXCLUDE = /(node_modules|\\.yalc)/;\n"],"names":["JS_RULE_EXCLUDE"],"mappings":";;;;+BAAaA;;;eAAAA;;;AAAN,MAAMA,kBAAkB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/startup",
|
|
3
|
-
"version": "36.1.2-canary.
|
|
3
|
+
"version": "36.1.2-canary.6",
|
|
4
4
|
"description": "CLI to create multi-package Lerna projects with TypeScript and React",
|
|
5
5
|
"homepage": "https://docs.st.dev/docs/frontend/uikit/startup",
|
|
6
6
|
"repository": {
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"typings": "./dist/index.d.ts",
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
22
|
},
|
|
23
23
|
"./@types/cypress": {
|
|
24
24
|
"types": "./dist/cypress/types/index.d.ts"
|
|
@@ -97,19 +97,19 @@
|
|
|
97
97
|
"@jest/core": "~30.3.0",
|
|
98
98
|
"@jest/types": "~30.3.0",
|
|
99
99
|
"@jsdevtools/coverage-istanbul-loader": "^3.0.5",
|
|
100
|
-
"@servicetitan/eslint-config": "36.
|
|
101
|
-
"@servicetitan/install": "36.1.2-canary.
|
|
102
|
-
"@servicetitan/startup-utils": "36.
|
|
103
|
-
"@servicetitan/stylelint-config": "36.
|
|
100
|
+
"@servicetitan/eslint-config": "36.1.1",
|
|
101
|
+
"@servicetitan/install": "36.1.2-canary.6",
|
|
102
|
+
"@servicetitan/startup-utils": "36.1.1",
|
|
103
|
+
"@servicetitan/stylelint-config": "36.1.1",
|
|
104
104
|
"@svgr/webpack": "^8.1.0",
|
|
105
|
-
"@swc/cli": "^0.8.
|
|
106
|
-
"@swc/core": "1.15.
|
|
105
|
+
"@swc/cli": "^0.8.1",
|
|
106
|
+
"@swc/core": "1.15.24",
|
|
107
107
|
"@types/debug": "^4.1.12",
|
|
108
108
|
"@types/jest": "~30.0.0",
|
|
109
|
-
"@vitest/coverage-v8": "^4.1.
|
|
109
|
+
"@vitest/coverage-v8": "^4.1.4",
|
|
110
110
|
"chalk": "~4.1.2",
|
|
111
111
|
"cli-table3": "^0.6.5",
|
|
112
|
-
"cpx2": "8.0.
|
|
112
|
+
"cpx2": "8.0.2",
|
|
113
113
|
"css-loader": "~7.1.4",
|
|
114
114
|
"css-minimizer-webpack-plugin": "^8.0.0",
|
|
115
115
|
"debug": "^4.4.3",
|
|
@@ -138,9 +138,9 @@
|
|
|
138
138
|
"multimatch": "~8.0.0",
|
|
139
139
|
"patch-package": "^8.0.1",
|
|
140
140
|
"portfinder": "~1.0.38",
|
|
141
|
-
"postcss": "~8.5.
|
|
142
|
-
"prettier": "~3.8.
|
|
143
|
-
"sass": "~1.
|
|
141
|
+
"postcss": "~8.5.10",
|
|
142
|
+
"prettier": "~3.8.3",
|
|
143
|
+
"sass": "~1.99.0",
|
|
144
144
|
"sass-loader": "~16.0.7",
|
|
145
145
|
"semver": "~7.7.4",
|
|
146
146
|
"source-map-loader": "~5.0.0",
|
|
@@ -149,12 +149,12 @@
|
|
|
149
149
|
"swc-loader": "^0.2.7",
|
|
150
150
|
"terminal-link": "^5.0.0",
|
|
151
151
|
"terser-webpack-plugin": "^5.4.0",
|
|
152
|
-
"ts-jest": "29.4.
|
|
152
|
+
"ts-jest": "29.4.9",
|
|
153
153
|
"ts-node": "~10.9.2",
|
|
154
154
|
"typed-css-modules": "~0.9.1",
|
|
155
155
|
"typescript": "5.9.3",
|
|
156
|
-
"vitest": "^4.1.
|
|
157
|
-
"webpack": "~5.
|
|
156
|
+
"vitest": "^4.1.4",
|
|
157
|
+
"webpack": "~5.106.2",
|
|
158
158
|
"webpack-assets-manifest": "~6.5.1",
|
|
159
159
|
"webpack-bundle-analyzer": "^5.3.0",
|
|
160
160
|
"webpack-dev-server": "~5.2.3",
|
|
@@ -23,16 +23,10 @@ export class Clean extends Command<typeof entry> {
|
|
|
23
23
|
async execute() {
|
|
24
24
|
const processTree = new ProcessTree<typeof CleanProcesses>();
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
processTree.add(CleanProcesses.ResetNx, () =>
|
|
29
|
-
this.runCommand(`${packageManager.execCommand} nx reset`)
|
|
30
|
-
);
|
|
31
|
-
processTree.add(CleanProcesses.ClearJestCache, () =>
|
|
32
|
-
this.runCommand(`${packageManager.execCommand} jest --clearCache`)
|
|
33
|
-
);
|
|
26
|
+
processTree.add(CleanProcesses.ResetNx, () => this.runCommand('nx reset'));
|
|
27
|
+
processTree.add(CleanProcesses.ClearJestCache, () => this.runCommand('jest --clearCache'));
|
|
34
28
|
processTree.add(CleanProcesses.ClearPackageManagerCache, () =>
|
|
35
|
-
Promise.resolve(this.clearPackageManagerCache(
|
|
29
|
+
Promise.resolve(this.clearPackageManagerCache())
|
|
36
30
|
);
|
|
37
31
|
processTree.add(CleanProcesses.ClearNpxCache, () => this.clearNpxCache());
|
|
38
32
|
|
|
@@ -69,8 +63,9 @@ export class Clean extends Command<typeof entry> {
|
|
|
69
63
|
}
|
|
70
64
|
}
|
|
71
65
|
|
|
72
|
-
private clearPackageManagerCache(
|
|
66
|
+
private clearPackageManagerCache() {
|
|
73
67
|
try {
|
|
68
|
+
const packageManager = getPackageManager();
|
|
74
69
|
log.info(`Clearing ${packageManager.command} cache`);
|
|
75
70
|
packageManager.clearCache();
|
|
76
71
|
} catch (error) {
|
|
@@ -1,70 +1,106 @@
|
|
|
1
1
|
import { execSync } from 'child_process';
|
|
2
|
+
import { MockPackageManager } from '../../__mocks__';
|
|
2
3
|
import { ErrorSeverity, FixCategory } from '../../types';
|
|
4
|
+
import { mockProject } from '../__mocks__/mock-project';
|
|
3
5
|
import { RequireNpmrc } from '../require-npmrc';
|
|
4
6
|
|
|
5
7
|
jest.mock('child_process', () => ({ execSync: jest.fn() }));
|
|
6
8
|
|
|
7
9
|
describe(`[startup] Review ${RequireNpmrc.name}`, () => {
|
|
10
|
+
const id = 'require-npmrc';
|
|
8
11
|
const rule = new RequireNpmrc();
|
|
9
12
|
let npmConfig: Record<string, any>;
|
|
13
|
+
let project: ReturnType<typeof mockProject>;
|
|
10
14
|
|
|
11
|
-
beforeEach(() =>
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
jest.clearAllMocks();
|
|
17
|
+
npmConfig = {};
|
|
18
|
+
project = mockProject({});
|
|
19
|
+
});
|
|
12
20
|
|
|
13
21
|
const subject = () => {
|
|
14
22
|
jest.mocked(execSync).mockImplementation(() => JSON.stringify(npmConfig));
|
|
15
|
-
return rule.run();
|
|
23
|
+
return rule.run(project);
|
|
16
24
|
};
|
|
17
25
|
|
|
18
|
-
function itReturnsWarning() {
|
|
19
|
-
test('returns warning', () => {
|
|
20
|
-
expect(subject()).toEqual({
|
|
21
|
-
id: expect.any(String),
|
|
22
|
-
message: 'project does not contain .npmrc with legacy-peer-deps=true',
|
|
23
|
-
severity: ErrorSeverity.warning,
|
|
24
|
-
fixable: FixCategory.isolated,
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function itReturnsNothing() {
|
|
30
|
-
test('returns nothing', () => {
|
|
31
|
-
expect(subject()).toBeUndefined();
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
26
|
test('fetches npm settings', () => {
|
|
36
27
|
subject();
|
|
37
28
|
|
|
38
|
-
expect(execSync).toHaveBeenCalledWith(
|
|
29
|
+
expect(execSync).toHaveBeenCalledWith('npm config list --json', { encoding: 'utf8' });
|
|
39
30
|
});
|
|
40
31
|
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
const REQUIRED_SETTINGS: {
|
|
33
|
+
setting: string;
|
|
34
|
+
packageManager?: 'npm' | 'pnpm';
|
|
35
|
+
severity?: ErrorSeverity;
|
|
36
|
+
}[] = [{ setting: 'legacy-peer-deps', packageManager: 'npm', severity: ErrorSeverity.warning }];
|
|
37
|
+
|
|
38
|
+
describe.each(REQUIRED_SETTINGS)('$setting', ({ setting, packageManager, severity }) => {
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
npmConfig = REQUIRED_SETTINGS.reduce(
|
|
41
|
+
(result, { setting }) => Object.assign(result, { [setting]: true }),
|
|
42
|
+
{}
|
|
43
|
+
);
|
|
44
|
+
});
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
function itReturnsError() {
|
|
47
|
+
test(`returns ${severity === ErrorSeverity.warning ? 'warning' : 'error'}`, () => {
|
|
48
|
+
expect(subject()).toContainEqual(
|
|
49
|
+
expect.objectContaining({
|
|
50
|
+
id,
|
|
51
|
+
message: `project does not contain .npmrc with ${setting}=true`,
|
|
52
|
+
severity,
|
|
53
|
+
fixable: FixCategory.isolated,
|
|
54
|
+
})
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
46
58
|
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
function itReturnsNothing() {
|
|
60
|
+
test('returns nothing', () => {
|
|
61
|
+
expect(subject()).toEqual([]);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
describe.each([undefined, false])('when %s', value => {
|
|
66
|
+
beforeEach(() => {
|
|
67
|
+
if (value === undefined) {
|
|
68
|
+
delete npmConfig[setting];
|
|
69
|
+
} else {
|
|
70
|
+
npmConfig[setting] = value;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
49
73
|
|
|
50
|
-
|
|
51
|
-
|
|
74
|
+
if (!packageManager) {
|
|
75
|
+
itReturnsError();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
52
78
|
|
|
53
|
-
|
|
54
|
-
beforeEach(() => (npmConfig = { 'legacy-peer-deps': false }));
|
|
79
|
+
itReturnsNothing();
|
|
55
80
|
|
|
56
|
-
|
|
57
|
-
|
|
81
|
+
describe(`when package manager is ${packageManager}`, () => {
|
|
82
|
+
beforeEach(() => {
|
|
83
|
+
(project.packageManager as MockPackageManager).command = packageManager;
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
itReturnsError();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
58
89
|
|
|
59
|
-
|
|
60
|
-
|
|
90
|
+
describe('when true', () => {
|
|
91
|
+
beforeEach(() => (npmConfig[setting] = true));
|
|
61
92
|
|
|
62
|
-
|
|
63
|
-
|
|
93
|
+
itReturnsNothing();
|
|
94
|
+
});
|
|
64
95
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
96
|
+
describe('fix', () => {
|
|
97
|
+
test(`sets ${setting}=true`, () => {
|
|
98
|
+
rule.fix({ id: rule.id, data: setting, message: '' });
|
|
99
|
+
|
|
100
|
+
expect(execSync).toHaveBeenCalledWith(
|
|
101
|
+
`npm config set --location=project ${setting}=true`
|
|
102
|
+
);
|
|
103
|
+
});
|
|
68
104
|
});
|
|
69
105
|
});
|
|
70
106
|
});
|
|
@@ -1,26 +1,44 @@
|
|
|
1
1
|
import { execSync } from 'child_process';
|
|
2
2
|
import { log } from '../../../../utils';
|
|
3
|
-
import { ErrorSeverity, FixCategory, PackageError, PackageRule } from '../types';
|
|
3
|
+
import { ErrorSeverity, FixCategory, PackageError, PackageRule, Project } from '../types';
|
|
4
|
+
|
|
5
|
+
interface RequiresSetting {
|
|
6
|
+
key: string;
|
|
7
|
+
packageManager?: 'npm' | 'pnpm';
|
|
8
|
+
severity?: ErrorSeverity;
|
|
9
|
+
}
|
|
10
|
+
const REQUIRED_SETTINGS: RequiresSetting[] = [
|
|
11
|
+
{ key: 'legacy-peer-deps', packageManager: 'npm', severity: ErrorSeverity.warning },
|
|
12
|
+
];
|
|
4
13
|
|
|
5
14
|
export class RequireNpmrc implements PackageRule {
|
|
6
15
|
get id() {
|
|
7
16
|
return 'require-npmrc';
|
|
8
17
|
}
|
|
9
18
|
|
|
10
|
-
run(): PackageError
|
|
19
|
+
run(project: Project): PackageError[] {
|
|
11
20
|
const stdout = execSync('npm config list --json', { encoding: 'utf8' });
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
const config = JSON.parse(stdout);
|
|
22
|
+
|
|
23
|
+
function omitsRequiredSetting({ key, packageManager }: RequiresSetting) {
|
|
24
|
+
return (
|
|
25
|
+
config[key] !== true &&
|
|
26
|
+
(!packageManager || packageManager === project.packageManager.command)
|
|
27
|
+
);
|
|
19
28
|
}
|
|
29
|
+
|
|
30
|
+
return REQUIRED_SETTINGS.filter(omitsRequiredSetting).map(({ key, severity }) => ({
|
|
31
|
+
id: this.id,
|
|
32
|
+
data: key,
|
|
33
|
+
location: '.npmrc',
|
|
34
|
+
message: `project does not contain .npmrc with ${key}=true`,
|
|
35
|
+
severity,
|
|
36
|
+
fixable: FixCategory.isolated,
|
|
37
|
+
}));
|
|
20
38
|
}
|
|
21
39
|
|
|
22
|
-
fix() {
|
|
23
|
-
const command =
|
|
40
|
+
fix(error: PackageError<string>) {
|
|
41
|
+
const command = `npm config set --location=project ${error.data}=true`;
|
|
24
42
|
log.debug(`review:${this.id}`, `Running ${command}`);
|
|
25
43
|
execSync(command);
|
|
26
44
|
}
|
|
@@ -45,6 +45,15 @@ describe(`[startup/cypress-config] ${webpackConfig.name}`, () => {
|
|
|
45
45
|
);
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
+
test('enables code coverage', () => {
|
|
49
|
+
subject();
|
|
50
|
+
|
|
51
|
+
expect(rulesConfig).toHaveBeenCalledWith(
|
|
52
|
+
expect.objectContaining({ codeCoverage: true }),
|
|
53
|
+
expect.anything()
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
|
|
48
57
|
test('includes all rules from rulesConfig', () => {
|
|
49
58
|
const result = subject();
|
|
50
59
|
|
|
@@ -39,11 +39,7 @@ const EXTRA_BINS = [
|
|
|
39
39
|
from: '@progress/kendo-licensing',
|
|
40
40
|
binPath: 'bin/kendo-ui-license.js',
|
|
41
41
|
},
|
|
42
|
-
{
|
|
43
|
-
name: 'nx',
|
|
44
|
-
from: 'nx',
|
|
45
|
-
binPath: 'bin/nx.js',
|
|
46
|
-
},
|
|
42
|
+
{ name: 'nx', from: 'nx', binPath: 'bin/nx.js' },
|
|
47
43
|
];
|
|
48
44
|
|
|
49
45
|
/*
|
|
@@ -137,10 +133,7 @@ function generateWrappers(binDirectory, bins) {
|
|
|
137
133
|
|
|
138
134
|
for (const { name, from, binPath } of bins) {
|
|
139
135
|
const wrapperPath = path.join(binDirectory, `${name}.js`);
|
|
140
|
-
const wrapper = `#!/usr/bin/env node
|
|
141
|
-
// ${GENERATED_MARKER} - wraps: ${from} -> ${binPath}
|
|
142
|
-
require('./_run')('${from}', '${binPath}');
|
|
143
|
-
`;
|
|
136
|
+
const wrapper = `#!/usr/bin/env node\n// ${GENERATED_MARKER} - wraps: ${from} -> ${binPath}\nrequire('./_run')('${from}', '${binPath}');\n`;
|
|
144
137
|
const existing = fs.existsSync(wrapperPath) && fs.readFileSync(wrapperPath, 'utf8');
|
|
145
138
|
const normalized = existing && existing.replace(/\r\n/g, '\n');
|
|
146
139
|
if (normalized !== wrapper) {
|
|
@@ -49,6 +49,31 @@ describe(`[startup/storybook-config] ${webpackFinal.name}`, () => {
|
|
|
49
49
|
);
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
+
describe('when config has optimization settings', () => {
|
|
53
|
+
beforeEach(() => {
|
|
54
|
+
config.optimization = { sideEffects: true, splitChunks: { chunks: 'all' } };
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('when mode is development', () => {
|
|
58
|
+
beforeEach(() => (config.mode = 'development'));
|
|
59
|
+
|
|
60
|
+
test('disables sideEffects to preserve CSS imports from barrel files', () => {
|
|
61
|
+
expect(subject().optimization).toEqual({
|
|
62
|
+
...config.optimization,
|
|
63
|
+
sideEffects: false,
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe('when mode is production', () => {
|
|
69
|
+
beforeEach(() => (config.mode = 'production'));
|
|
70
|
+
|
|
71
|
+
test('does not change sideEffects', () => {
|
|
72
|
+
expect(subject().optimization).toEqual(config.optimization);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
52
77
|
test('adds MiniCssExtractPlugin to config', () => {
|
|
53
78
|
expect(subject().plugins).toEqual([mockMiniCssExtractPlugin]);
|
|
54
79
|
});
|
|
@@ -14,6 +14,10 @@ export function webpackFinal(config: Configuration, overrides: Overrides = {}):
|
|
|
14
14
|
|
|
15
15
|
return {
|
|
16
16
|
...config,
|
|
17
|
+
optimization: {
|
|
18
|
+
...config.optimization,
|
|
19
|
+
...(config.mode !== 'production' ? { sideEffects: false } : {}),
|
|
20
|
+
},
|
|
17
21
|
module: {
|
|
18
22
|
...config.module,
|
|
19
23
|
rules: [...transformDefaultRules(config.module?.rules), ...rules],
|