@servicetitan/startup 32.1.0 → 32.2.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/dist/cli/commands/test/runners/vitest.js +2 -1
- package/dist/cli/commands/test/runners/vitest.js.map +1 -1
- package/dist/cli/utils/bundle.js +1 -1
- package/dist/cli/utils/bundle.js.map +1 -1
- package/dist/cli/utils/maybe-create-git-folder.d.ts.map +1 -1
- package/dist/cli/utils/maybe-create-git-folder.js +7 -1
- package/dist/cli/utils/maybe-create-git-folder.js.map +1 -1
- package/dist/utils/get-configuration.d.ts +9 -3
- package/dist/utils/get-configuration.d.ts.map +1 -1
- package/dist/utils/get-configuration.js.map +1 -1
- package/dist/utils/get-jest-config.d.ts.map +1 -1
- package/dist/utils/get-jest-config.js +20 -9
- package/dist/utils/get-jest-config.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/omit.d.ts +2 -0
- package/dist/utils/omit.d.ts.map +1 -0
- package/dist/utils/omit.js +28 -0
- package/dist/utils/omit.js.map +1 -0
- package/package.json +22 -17
- package/src/cli/commands/test/runners/__tests__/vitest.test.ts +82 -13
- package/src/cli/commands/test/runners/vitest.ts +4 -2
- package/src/cli/utils/__tests__/maybe-create-git-folder.test.ts +1 -1
- package/src/cli/utils/bundle.ts +1 -1
- package/src/cli/utils/maybe-create-git-folder.ts +6 -1
- package/src/utils/__tests__/get-jest-config.test.ts +44 -0
- package/src/utils/get-configuration.ts +6 -2
- package/src/utils/get-jest-config.ts +36 -18
- package/src/utils/index.ts +1 -0
- package/src/utils/omit.ts +12 -0
|
@@ -75,8 +75,9 @@ function getDefaultConfig() {
|
|
|
75
75
|
}
|
|
76
76
|
async function getUserConfig() {
|
|
77
77
|
const { viteConfig } = await (0, _node.resolveConfig)();
|
|
78
|
+
const { omitDefault = [], ...config } = (0, _utils.getVitestConfiguration)();
|
|
78
79
|
var _viteConfig_test;
|
|
79
|
-
const result = (0, _config.mergeConfig)((0, _config.mergeConfig)(
|
|
80
|
+
const result = (0, _config.mergeConfig)((0, _config.mergeConfig)((0, _utils.omit)(getDefaultConfig(), omitDefault), config), (_viteConfig_test = viteConfig.test) !== null && _viteConfig_test !== void 0 ? _viteConfig_test : {});
|
|
80
81
|
/* istanbul ignore next: debug only */ _utils.log.debug('vitest:userConfig', ()=>JSON.stringify(result, null, 2));
|
|
81
82
|
return {
|
|
82
83
|
test: result
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/cli/commands/test/runners/vitest.ts"],"sourcesContent":["import { configDefaults, coverageConfigDefaults, mergeConfig, ViteUserConfig } from 'vitest/config';\nimport { startVitest, parseCLI, resolveConfig } from 'vitest/node';\nimport { getVitestConfiguration, log } from '../../../../utils';\n\ntype VitestConfig = NonNullable<ViteUserConfig['test']>;\n\nexport class Vitest {\n async run() {\n const cliOptions = getCliOptions();\n const userConfig = await getUserConfig();\n\n // startVitest sets process.exitCode to 1 when tests fail\n const vitest = await startVitest('test', cliOptions.filter, cliOptions.options, userConfig);\n await vitest.close();\n }\n}\n\nconst RUNNER_OPTION = '--runner';\n\nfunction excludeRunnerOption(args: string[]) {\n return args.reduce<string[]>((result, item, index) => {\n if (!item.startsWith(RUNNER_OPTION) && (index === 0 || args[index - 1] !== RUNNER_OPTION)) {\n result.push(item);\n }\n return result;\n }, []);\n}\n\nfunction getCliOptions() {\n // parseCLI requires the first element to be \"vitest\"\n const result = parseCLI(['vitest', ...excludeRunnerOption(process.argv.slice(3))]);\n\n /* istanbul ignore next: debug only */\n log.debug('vitest:cliOptions', () => JSON.stringify(result, null, 2));\n\n return result;\n}\n\nfunction getDefaultConfig(): VitestConfig {\n return {\n coverage: {\n exclude: [\n ...coverageConfigDefaults.exclude,\n '**/__mocks__/**',\n '**/*.stories.*',\n '\\\\.yalc',\n ],\n include: ['**/*.{ts,tsx}'],\n reporter: ['html-spa', 'text', 'json', 'cobertura', 'lcov'],\n },\n environment: 'jsdom',\n exclude: [...configDefaults.exclude, '\\\\.yalc'],\n restoreMocks: true,\n server: { deps: { inline: ['@servicetitan/anvil2'] } }, // fixes css parser errors\n };\n}\n\nasync function getUserConfig(): Promise<ViteUserConfig> {\n const { viteConfig } = await resolveConfig();\n\n const result = mergeConfig(\n mergeConfig(getDefaultConfig(),
|
|
1
|
+
{"version":3,"sources":["../../../../../src/cli/commands/test/runners/vitest.ts"],"sourcesContent":["import { configDefaults, coverageConfigDefaults, mergeConfig, ViteUserConfig } from 'vitest/config';\nimport { startVitest, parseCLI, resolveConfig } from 'vitest/node';\nimport { getVitestConfiguration, log, omit } from '../../../../utils';\n\ntype VitestConfig = NonNullable<ViteUserConfig['test']>;\n\nexport class Vitest {\n async run() {\n const cliOptions = getCliOptions();\n const userConfig = await getUserConfig();\n\n // startVitest sets process.exitCode to 1 when tests fail\n const vitest = await startVitest('test', cliOptions.filter, cliOptions.options, userConfig);\n await vitest.close();\n }\n}\n\nconst RUNNER_OPTION = '--runner';\n\nfunction excludeRunnerOption(args: string[]) {\n return args.reduce<string[]>((result, item, index) => {\n if (!item.startsWith(RUNNER_OPTION) && (index === 0 || args[index - 1] !== RUNNER_OPTION)) {\n result.push(item);\n }\n return result;\n }, []);\n}\n\nfunction getCliOptions() {\n // parseCLI requires the first element to be \"vitest\"\n const result = parseCLI(['vitest', ...excludeRunnerOption(process.argv.slice(3))]);\n\n /* istanbul ignore next: debug only */\n log.debug('vitest:cliOptions', () => JSON.stringify(result, null, 2));\n\n return result;\n}\n\nfunction getDefaultConfig(): VitestConfig {\n return {\n coverage: {\n exclude: [\n ...coverageConfigDefaults.exclude,\n '**/__mocks__/**',\n '**/*.stories.*',\n '\\\\.yalc',\n ],\n include: ['**/*.{ts,tsx}'],\n reporter: ['html-spa', 'text', 'json', 'cobertura', 'lcov'],\n },\n environment: 'jsdom',\n exclude: [...configDefaults.exclude, '\\\\.yalc'],\n restoreMocks: true,\n server: { deps: { inline: ['@servicetitan/anvil2'] } }, // fixes css parser errors\n };\n}\n\nasync function getUserConfig(): Promise<ViteUserConfig> {\n const { viteConfig } = await resolveConfig();\n\n const { omitDefault = [], ...config } = getVitestConfiguration();\n\n const result = mergeConfig(\n mergeConfig(omit(getDefaultConfig(), omitDefault), config),\n viteConfig.test ?? {}\n );\n\n /* istanbul ignore next: debug only */\n log.debug('vitest:userConfig', () => JSON.stringify(result, null, 2));\n\n return { test: result };\n}\n"],"names":["Vitest","run","cliOptions","getCliOptions","userConfig","getUserConfig","vitest","startVitest","filter","options","close","RUNNER_OPTION","excludeRunnerOption","args","reduce","result","item","index","startsWith","push","parseCLI","process","argv","slice","log","debug","JSON","stringify","getDefaultConfig","coverage","exclude","coverageConfigDefaults","include","reporter","environment","configDefaults","restoreMocks","server","deps","inline","viteConfig","resolveConfig","omitDefault","config","getVitestConfiguration","mergeConfig","omit","test"],"mappings":";;;;+BAMaA;;;eAAAA;;;wBANuE;sBAC/B;uBACH;AAI3C,MAAMA;IACT,MAAMC,MAAM;QACR,MAAMC,aAAaC;QACnB,MAAMC,aAAa,MAAMC;QAEzB,yDAAyD;QACzD,MAAMC,SAAS,MAAMC,IAAAA,iBAAW,EAAC,QAAQL,WAAWM,MAAM,EAAEN,WAAWO,OAAO,EAAEL;QAChF,MAAME,OAAOI,KAAK;IACtB;AACJ;AAEA,MAAMC,gBAAgB;AAEtB,SAASC,oBAAoBC,IAAc;IACvC,OAAOA,KAAKC,MAAM,CAAW,CAACC,QAAQC,MAAMC;QACxC,IAAI,CAACD,KAAKE,UAAU,CAACP,kBAAmBM,CAAAA,UAAU,KAAKJ,IAAI,CAACI,QAAQ,EAAE,KAAKN,aAAY,GAAI;YACvFI,OAAOI,IAAI,CAACH;QAChB;QACA,OAAOD;IACX,GAAG,EAAE;AACT;AAEA,SAASZ;IACL,qDAAqD;IACrD,MAAMY,SAASK,IAAAA,cAAQ,EAAC;QAAC;WAAaR,oBAAoBS,QAAQC,IAAI,CAACC,KAAK,CAAC;KAAI;IAEjF,oCAAoC,GACpCC,UAAG,CAACC,KAAK,CAAC,qBAAqB,IAAMC,KAAKC,SAAS,CAACZ,QAAQ,MAAM;IAElE,OAAOA;AACX;AAEA,SAASa;IACL,OAAO;QACHC,UAAU;YACNC,SAAS;mBACFC,8BAAsB,CAACD,OAAO;gBACjC;gBACA;gBACA;aACH;YACDE,SAAS;gBAAC;aAAgB;YAC1BC,UAAU;gBAAC;gBAAY;gBAAQ;gBAAQ;gBAAa;aAAO;QAC/D;QACAC,aAAa;QACbJ,SAAS;eAAIK,sBAAc,CAACL,OAAO;YAAE;SAAU;QAC/CM,cAAc;QACdC,QAAQ;YAAEC,MAAM;gBAAEC,QAAQ;oBAAC;iBAAuB;YAAC;QAAE;IACzD;AACJ;AAEA,eAAelC;IACX,MAAM,EAAEmC,UAAU,EAAE,GAAG,MAAMC,IAAAA,mBAAa;IAE1C,MAAM,EAAEC,cAAc,EAAE,EAAE,GAAGC,QAAQ,GAAGC,IAAAA,6BAAsB;QAI1DJ;IAFJ,MAAMzB,SAAS8B,IAAAA,mBAAW,EACtBA,IAAAA,mBAAW,EAACC,IAAAA,WAAI,EAAClB,oBAAoBc,cAAcC,SACnDH,CAAAA,mBAAAA,WAAWO,IAAI,cAAfP,8BAAAA,mBAAmB,CAAC;IAGxB,oCAAoC,GACpChB,UAAG,CAACC,KAAK,CAAC,qBAAqB,IAAMC,KAAKC,SAAS,CAACZ,QAAQ,MAAM;IAElE,OAAO;QAAEgC,MAAMhC;IAAO;AAC1B"}
|
package/dist/cli/utils/bundle.js
CHANGED
|
@@ -173,7 +173,7 @@ async function runWatch(config) {
|
|
|
173
173
|
return new Promise((_0, reject)=>{
|
|
174
174
|
const watching = compiler.watch({}, (e)=>{
|
|
175
175
|
if (e) {
|
|
176
|
-
watching.close(()=>{
|
|
176
|
+
watching === null || watching === void 0 ? void 0 : watching.close(()=>{
|
|
177
177
|
reject(e);
|
|
178
178
|
});
|
|
179
179
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/utils/bundle.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport crypto from 'crypto';\nimport { getPortPromise } from 'portfinder';\n\nimport webpack, { Configuration } from 'webpack';\nimport WebpackDevServer from 'webpack-dev-server';\n\nimport {\n getPackageName,\n hasHeadlessBundle,\n isDevServerDisabled,\n isExposeSharedDependencies,\n isWebComponent,\n log,\n pick,\n} from '../../utils';\nimport { Overrides, createWebpackConfig } from '../../webpack';\nimport { stringifyConfig } from '../../webpack/utils';\n\ninterface Options {\n buildStat?: boolean;\n codeCoverage?: boolean;\n config?: string;\n emitExposedDependencies?: boolean | Pick<Configuration, 'output'>;\n useWatchConfig?: boolean;\n watch?: boolean;\n}\n\nfunction getName() {\n const packageName = getPackageName()\n .replace(/\\//g, '-')\n .replace(/[^\\w-]/g, '');\n const hash = crypto.randomBytes(4).toString('hex');\n\n return `${packageName}-${hash}`;\n}\n\nexport const webpackDevConfigFileName = 'webpack.dev.config.js';\nexport const webpackProdConfigFileName = 'webpack.prod.config.js';\n\nexport async function bundle(options: Options = {}) {\n const { emitExposedDependencies, useWatchConfig, watch } = options;\n if (emitExposedDependencies) {\n if (watch) {\n throw new Error('cannot bundle exposed dependencies in watch mode');\n }\n if (!isExposeSharedDependencies()) {\n return;\n }\n }\n\n log.info(`Bundling ${emitExposedDependencies ? 'exposed dependencies' : 'package'}...`);\n\n const mode = watch ? 'development' : 'production';\n const fallback = watch || useWatchConfig ? webpackDevConfigFileName : webpackProdConfigFileName;\n const customConfig = readWebpackConfig({ ...options, fallback });\n const webpackOptions = getWebpackOptions(options, customConfig);\n\n /* istanbul ignore next: debug only */\n log.debug('custom-webpack-config', () => stringifyConfig(customConfig));\n\n if (isWebComponent()) {\n return bundleWebComponent({ customConfig, mode, watch, webpackOptions });\n }\n\n const config =\n customConfig && !emitExposedDependencies\n ? customConfig\n : createWebpackConfig({ configuration: { mode } }, webpackOptions);\n\n if (watch) {\n return isDevServerDisabled() ? runWatch(config) : runServe(config);\n }\n\n return run(config);\n}\n\nfunction bundleWebComponent({\n customConfig,\n mode,\n watch,\n webpackOptions,\n}: {\n customConfig: ReturnType<typeof readWebpackConfig>;\n mode: 'development' | 'production';\n watch?: boolean;\n webpackOptions: ReturnType<typeof getWebpackOptions>;\n}) {\n const overrides: Overrides = {\n configuration: { ...customConfig?.configuration, mode },\n plugins: customConfig?.plugins,\n };\n\n const fullConfig = createWebpackConfig(overrides, webpackOptions);\n const lightConfig = createWebpackConfig(overrides, { ...webpackOptions, embed: true });\n const headlessConfig = hasHeadlessBundle()\n ? createWebpackConfig(overrides, {\n ...webpackOptions,\n headless: true,\n })\n : undefined;\n\n const promises = watch\n ? [\n runWatch(lightConfig),\n isDevServerDisabled() ? runWatch(fullConfig) : runServe(fullConfig),\n headlessConfig && runWatch(headlessConfig),\n ]\n : [run(lightConfig), run(fullConfig), headlessConfig && run(headlessConfig)];\n\n return Promise.all(promises.filter(promise => !!promise));\n}\n\nfunction getWebpackOptions(options: Options, customConfig?: Record<string, any>) {\n const result = {\n name: getName(),\n ...pick(options, ['buildStat', 'codeCoverage', 'emitExposedDependencies']),\n };\n\n if (result.emitExposedDependencies && customConfig) {\n result.emitExposedDependencies = { output: customConfig.output };\n }\n\n return result;\n}\n\nfunction readWebpackConfig({ config, fallback }: Options & { fallback: string }) {\n return readConfig(config) ?? readConfig(fallback);\n}\n\nfunction readConfig(relativePath?: string): Record<string, any> | undefined {\n if (relativePath && fs.existsSync(relativePath)) {\n return require(path.resolve(relativePath));\n }\n}\n\nasync function run(config: Configuration) {\n const compiler = createWebpackCompiler(config);\n\n const stats = await new Promise<webpack.Stats>((resolve, reject) => {\n compiler.run((error, stats) => {\n if (!stats || error) {\n return reject(error ?? new Error('Something went wrong.'));\n }\n\n if (stats.hasErrors()) {\n return reject(new Error(stats.toString('errors-only')));\n }\n\n compiler.close(() => resolve(stats));\n });\n });\n\n process.stdout.write(stats.toString(config.stats) + '\\n');\n}\n\nasync function runServe({ devServer = {}, ...config }: Configuration) {\n const compiler = createWebpackCompiler(config);\n const host = devServer.host ?? 'localhost';\n const port = await getPortPromise({\n port: Number(devServer.port) || 8080,\n host,\n });\n\n return new Promise<void>((_0, reject) => {\n const server = new WebpackDevServer({ ...devServer, host, port }, compiler);\n server.startCallback(e => {\n if (e) {\n server.stopCallback(() => {\n reject(e);\n });\n }\n });\n });\n}\n\nasync function runWatch(config: Configuration) {\n const compiler = createWebpackCompiler(config);\n return new Promise<void>((_0, reject) => {\n const watching = compiler.watch({}, e => {\n if (e) {\n watching.close(() => {\n reject(e);\n });\n }\n });\n });\n}\n\nfunction createWebpackCompiler(config: Configuration) {\n return webpack(config)!; // webpack only potentially returns null when given a callback argument\n}\n"],"names":["bundle","webpackDevConfigFileName","webpackProdConfigFileName","getName","packageName","getPackageName","replace","hash","crypto","randomBytes","toString","options","emitExposedDependencies","useWatchConfig","watch","Error","isExposeSharedDependencies","log","info","mode","fallback","customConfig","readWebpackConfig","webpackOptions","getWebpackOptions","debug","stringifyConfig","isWebComponent","bundleWebComponent","config","createWebpackConfig","configuration","isDevServerDisabled","runWatch","runServe","run","overrides","plugins","fullConfig","lightConfig","embed","headlessConfig","hasHeadlessBundle","headless","undefined","promises","Promise","all","filter","promise","result","name","pick","output","readConfig","relativePath","fs","existsSync","require","path","resolve","compiler","createWebpackCompiler","stats","reject","error","hasErrors","close","process","stdout","write","devServer","host","port","getPortPromise","Number","_0","server","WebpackDevServer","startCallback","e","stopCallback","watching","webpack"],"mappings":";;;;;;;;;;;QAyCsBA;eAAAA;;QAHTC;eAAAA;;QACAC;eAAAA;;;2DAvCE;6DACE;+DACE;4BACY;gEAEQ;yEACV;uBAUtB;0BACwC;wBACf;;;;;;AAWhC,SAASC;IACL,MAAMC,cAAcC,IAAAA,qBAAc,IAC7BC,OAAO,CAAC,OAAO,KACfA,OAAO,CAAC,WAAW;IACxB,MAAMC,OAAOC,eAA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sBAAsBjC,MAAqB;IAChD,OAAOsD,IAAAA,gBAAO,EAACtD,SAAU,uEAAuE;AACpG"}
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/utils/bundle.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport crypto from 'crypto';\nimport { getPortPromise } from 'portfinder';\n\nimport webpack, { Configuration } from 'webpack';\nimport WebpackDevServer from 'webpack-dev-server';\n\nimport {\n getPackageName,\n hasHeadlessBundle,\n isDevServerDisabled,\n isExposeSharedDependencies,\n isWebComponent,\n log,\n pick,\n} from '../../utils';\nimport { Overrides, createWebpackConfig } from '../../webpack';\nimport { stringifyConfig } from '../../webpack/utils';\n\ninterface Options {\n buildStat?: boolean;\n codeCoverage?: boolean;\n config?: string;\n emitExposedDependencies?: boolean | Pick<Configuration, 'output'>;\n useWatchConfig?: boolean;\n watch?: boolean;\n}\n\nfunction getName() {\n const packageName = getPackageName()\n .replace(/\\//g, '-')\n .replace(/[^\\w-]/g, '');\n const hash = crypto.randomBytes(4).toString('hex');\n\n return `${packageName}-${hash}`;\n}\n\nexport const webpackDevConfigFileName = 'webpack.dev.config.js';\nexport const webpackProdConfigFileName = 'webpack.prod.config.js';\n\nexport async function bundle(options: Options = {}) {\n const { emitExposedDependencies, useWatchConfig, watch } = options;\n if (emitExposedDependencies) {\n if (watch) {\n throw new Error('cannot bundle exposed dependencies in watch mode');\n }\n if (!isExposeSharedDependencies()) {\n return;\n }\n }\n\n log.info(`Bundling ${emitExposedDependencies ? 'exposed dependencies' : 'package'}...`);\n\n const mode = watch ? 'development' : 'production';\n const fallback = watch || useWatchConfig ? webpackDevConfigFileName : webpackProdConfigFileName;\n const customConfig = readWebpackConfig({ ...options, fallback });\n const webpackOptions = getWebpackOptions(options, customConfig);\n\n /* istanbul ignore next: debug only */\n log.debug('custom-webpack-config', () => stringifyConfig(customConfig));\n\n if (isWebComponent()) {\n return bundleWebComponent({ customConfig, mode, watch, webpackOptions });\n }\n\n const config =\n customConfig && !emitExposedDependencies\n ? customConfig\n : createWebpackConfig({ configuration: { mode } }, webpackOptions);\n\n if (watch) {\n return isDevServerDisabled() ? runWatch(config) : runServe(config);\n }\n\n return run(config);\n}\n\nfunction bundleWebComponent({\n customConfig,\n mode,\n watch,\n webpackOptions,\n}: {\n customConfig: ReturnType<typeof readWebpackConfig>;\n mode: 'development' | 'production';\n watch?: boolean;\n webpackOptions: ReturnType<typeof getWebpackOptions>;\n}) {\n const overrides: Overrides = {\n configuration: { ...customConfig?.configuration, mode },\n plugins: customConfig?.plugins,\n };\n\n const fullConfig = createWebpackConfig(overrides, webpackOptions);\n const lightConfig = createWebpackConfig(overrides, { ...webpackOptions, embed: true });\n const headlessConfig = hasHeadlessBundle()\n ? createWebpackConfig(overrides, {\n ...webpackOptions,\n headless: true,\n })\n : undefined;\n\n const promises = watch\n ? [\n runWatch(lightConfig),\n isDevServerDisabled() ? runWatch(fullConfig) : runServe(fullConfig),\n headlessConfig && runWatch(headlessConfig),\n ]\n : [run(lightConfig), run(fullConfig), headlessConfig && run(headlessConfig)];\n\n return Promise.all(promises.filter(promise => !!promise));\n}\n\nfunction getWebpackOptions(options: Options, customConfig?: Record<string, any>) {\n const result = {\n name: getName(),\n ...pick(options, ['buildStat', 'codeCoverage', 'emitExposedDependencies']),\n };\n\n if (result.emitExposedDependencies && customConfig) {\n result.emitExposedDependencies = { output: customConfig.output };\n }\n\n return result;\n}\n\nfunction readWebpackConfig({ config, fallback }: Options & { fallback: string }) {\n return readConfig(config) ?? readConfig(fallback);\n}\n\nfunction readConfig(relativePath?: string): Record<string, any> | undefined {\n if (relativePath && fs.existsSync(relativePath)) {\n return require(path.resolve(relativePath));\n }\n}\n\nasync function run(config: Configuration) {\n const compiler = createWebpackCompiler(config);\n\n const stats = await new Promise<webpack.Stats>((resolve, reject) => {\n compiler.run((error, stats) => {\n if (!stats || error) {\n return reject(error ?? new Error('Something went wrong.'));\n }\n\n if (stats.hasErrors()) {\n return reject(new Error(stats.toString('errors-only')));\n }\n\n compiler.close(() => resolve(stats));\n });\n });\n\n process.stdout.write(stats.toString(config.stats) + '\\n');\n}\n\nasync function runServe({ devServer = {}, ...config }: Configuration) {\n const compiler = createWebpackCompiler(config);\n const host = devServer.host ?? 'localhost';\n const port = await getPortPromise({\n port: Number(devServer.port) || 8080,\n host,\n });\n\n return new Promise<void>((_0, reject) => {\n const server = new WebpackDevServer({ ...devServer, host, port }, compiler);\n server.startCallback(e => {\n if (e) {\n server.stopCallback(() => {\n reject(e);\n });\n }\n });\n });\n}\n\nasync function runWatch(config: Configuration) {\n const compiler = createWebpackCompiler(config);\n return new Promise<void>((_0, reject) => {\n const watching = compiler.watch({}, e => {\n if (e) {\n watching?.close(() => {\n reject(e);\n });\n }\n });\n });\n}\n\nfunction createWebpackCompiler(config: Configuration) {\n return webpack(config)!; // webpack only potentially returns null when given a callback argument\n}\n"],"names":["bundle","webpackDevConfigFileName","webpackProdConfigFileName","getName","packageName","getPackageName","replace","hash","crypto","randomBytes","toString","options","emitExposedDependencies","useWatchConfig","watch","Error","isExposeSharedDependencies","log","info","mode","fallback","customConfig","readWebpackConfig","webpackOptions","getWebpackOptions","debug","stringifyConfig","isWebComponent","bundleWebComponent","config","createWebpackConfig","configuration","isDevServerDisabled","runWatch","runServe","run","overrides","plugins","fullConfig","lightConfig","embed","headlessConfig","hasHeadlessBundle","headless","undefined","promises","Promise","all","filter","promise","result","name","pick","output","readConfig","relativePath","fs","existsSync","require","path","resolve","compiler","createWebpackCompiler","stats","reject","error","hasErrors","close","process","stdout","write","devServer","host","port","getPortPromise","Number","_0","server","WebpackDevServer","startCallback","e","stopCallback","watching","webpack"],"mappings":";;;;;;;;;;;QAyCsBA;eAAAA;;QAHTC;eAAAA;;QACAC;eAAAA;;;2DAvCE;6DACE;+DACE;4BACY;gEAEQ;yEACV;uBAUtB;0BACwC;wBACf;;;;;;AAWhC,SAASC;IACL,MAAMC,cAAcC,IAAAA,qBAAc,IAC7BC,OAAO,CAAC,OAAO,KACfA,OAAO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ZH,OAAOgB;gBACX;YACJ;QACJ;IACJ;AACJ;AAEA,SAASlB,sBAAsBjC,MAAqB;IAChD,OAAOsD,IAAAA,gBAAO,EAACtD,SAAU,uEAAuE;AACpG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maybe-create-git-folder.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/maybe-create-git-folder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"maybe-create-git-folder.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/maybe-create-git-folder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,QAe7D"}
|
|
@@ -23,7 +23,13 @@ function maybeCreateGitFolder(command) {
|
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
if (!_fs.default.existsSync('.git')) {
|
|
26
|
-
|
|
26
|
+
/*
|
|
27
|
+
* Using {recursive: true} to ignore if directory exists. This happens
|
|
28
|
+
* when parallel process creates the directory after we've checked
|
|
29
|
+
* whether it exists.
|
|
30
|
+
*/ _fs.default.mkdirSync('.git', {
|
|
31
|
+
recursive: true
|
|
32
|
+
});
|
|
27
33
|
}
|
|
28
34
|
}
|
|
29
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/utils/maybe-create-git-folder.ts"],"sourcesContent":["import fs from 'fs';\n\nimport { Init } from '../commands/init';\nimport { Command, Newable } from '../commands/types';\n\n/**\n * Create empty .git folder to workaround issue where Lerna does not\n * detect workspace packages on Windows systems. The empty .git folder\n * causes nx to use the git-hasher when building the project graph.\n * Note this gets fixed (e.g., https://github.com/nrwl/nx/issues/8601) but\n * keeps reappearing (e.g., https://github.com/nrwl/nx/issues/9584 and\n * https://github.com/nrwl/nx/issues/18094)\n */\nexport function maybeCreateGitFolder(command: Newable<Command>) {\n if (process.platform !== 'win32') {\n return;\n }\n if (command === Init) {\n return;\n }\n if (!fs.existsSync('.git')) {\n fs.mkdirSync('.git');\n }\n}\n"],"names":["maybeCreateGitFolder","command","process","platform","Init","fs","existsSync","mkdirSync"],"mappings":";;;;+BAagBA;;;eAAAA;;;2DAbD;sBAEM;;;;;;AAWd,SAASA,qBAAqBC,OAAyB;IAC1D,IAAIC,QAAQC,QAAQ,KAAK,SAAS;QAC9B;IACJ;IACA,IAAIF,YAAYG,UAAI,EAAE;QAClB;IACJ;IACA,IAAI,CAACC,WAAE,CAACC,UAAU,CAAC,SAAS;
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/utils/maybe-create-git-folder.ts"],"sourcesContent":["import fs from 'fs';\n\nimport { Init } from '../commands/init';\nimport { Command, Newable } from '../commands/types';\n\n/**\n * Create empty .git folder to workaround issue where Lerna does not\n * detect workspace packages on Windows systems. The empty .git folder\n * causes nx to use the git-hasher when building the project graph.\n * Note this gets fixed (e.g., https://github.com/nrwl/nx/issues/8601) but\n * keeps reappearing (e.g., https://github.com/nrwl/nx/issues/9584 and\n * https://github.com/nrwl/nx/issues/18094)\n */\nexport function maybeCreateGitFolder(command: Newable<Command>) {\n if (process.platform !== 'win32') {\n return;\n }\n if (command === Init) {\n return;\n }\n if (!fs.existsSync('.git')) {\n /*\n * Using {recursive: true} to ignore if directory exists. This happens\n * when parallel process creates the directory after we've checked\n * whether it exists.\n */\n fs.mkdirSync('.git', { recursive: true });\n }\n}\n"],"names":["maybeCreateGitFolder","command","process","platform","Init","fs","existsSync","mkdirSync","recursive"],"mappings":";;;;+BAagBA;;;eAAAA;;;2DAbD;sBAEM;;;;;;AAWd,SAASA,qBAAqBC,OAAyB;IAC1D,IAAIC,QAAQC,QAAQ,KAAK,SAAS;QAC9B;IACJ;IACA,IAAIF,YAAYG,UAAI,EAAE;QAClB;IACJ;IACA,IAAI,CAACC,WAAE,CAACC,UAAU,CAAC,SAAS;QACxB;;;;SAIC,GACDD,WAAE,CAACE,SAAS,CAAC,QAAQ;YAAEC,WAAW;QAAK;IAC3C;AACJ"}
|
|
@@ -33,7 +33,9 @@ export interface StylelintConfiguration extends Partial<LinterOptions> {
|
|
|
33
33
|
ignorePattern?: string[];
|
|
34
34
|
disabled?: boolean;
|
|
35
35
|
}
|
|
36
|
-
export
|
|
36
|
+
export interface JestConfiguration extends Omit<Config.Argv, '_' | '$0'> {
|
|
37
|
+
omitDefault?: string[];
|
|
38
|
+
}
|
|
37
39
|
export interface NodeConfiguration {
|
|
38
40
|
NODE_OPTIONS?: string[];
|
|
39
41
|
}
|
|
@@ -58,7 +60,9 @@ export declare enum CommandName {
|
|
|
58
60
|
'task' = "task",
|
|
59
61
|
'upload-sourcemaps' = "upload-sourcemaps"
|
|
60
62
|
}
|
|
61
|
-
export type VitestConfiguration = ViteUserConfig['test']
|
|
63
|
+
export type VitestConfiguration = ViteUserConfig['test'] & {
|
|
64
|
+
omitDefault?: string[];
|
|
65
|
+
};
|
|
62
66
|
export interface WebComponentBranchConfigs {
|
|
63
67
|
publishTag?: string;
|
|
64
68
|
uploadSourcemaps?: boolean;
|
|
@@ -95,7 +99,9 @@ export declare function getESLintConfiguration(): ESLintConfiguration;
|
|
|
95
99
|
export declare function getJestConfiguration(): JestConfiguration;
|
|
96
100
|
export declare function getReviewConfiguration(): ReviewConfiguration & NodeConfiguration;
|
|
97
101
|
export declare function getStylelintConfiguration(): StylelintConfiguration;
|
|
98
|
-
export declare function getVitestConfiguration(): import("vitest/node").InlineConfig
|
|
102
|
+
export declare function getVitestConfiguration(): import("vitest/node").InlineConfig & {
|
|
103
|
+
omitDefault?: string[];
|
|
104
|
+
};
|
|
99
105
|
export declare function getWebpackConfiguration(locationOrJson?: LocationOrJson): WebpackConfiguration;
|
|
100
106
|
export declare function getWebComponentConfiguration(locationOrJson?: LocationOrJson): WebComponentOptions | undefined;
|
|
101
107
|
export declare function getWebComponentBranchConfigs(locationOrJson?: LocationOrJson): Record<string, WebComponentBranchConfigs> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-configuration.d.ts","sourceRoot":"","sources":["../../src/utils/get-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,aAAa,IAAI,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAEpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAK7D,eAAO,MAAM,8BAA8B,iDAAkD,CAAC;AAE9F,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,MAAM,WAAW,CAAC,EAAE,GAAG,WAAW,GAAG,KAAK,CAAC;AAErF,MAAM,WAAW,eAAe;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;CAAG;AAEpC,MAAM,WAAW,aAAa;IAC1B,GAAG,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC;IACjC,EAAE,CAAC,EAAE,OAAO,GAAG,eAAe,CAAC;CAClC;AAED,MAAM,WAAW,oBACb,SAAQ,IAAI,CACR,IAAI,CAAC,6BAA6B,EAAE,WAAW,CAAC,OAAO,8BAA8B,CAAC,CAAC,EACvF,OAAO,CACV;IACD,aAAa,CAAC,EAAE,OAAO,GAAG,MAA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BAAoB,CAAC;CAC5C,GAAG;KACC,GAAG,IAAI,WAAW,CAAC,CAAC,EAAE,iBAAiB;CAC3C,GAAG,iBAAiB,CAAC;AAEtB,KAAK,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAEnD,wBAAgB,gBAAgB,CAAC,cAAc,GAAE,cAAqB,GAAG,aAAa,CAMrF;AAED,wBAAgB,oBAAoB,CAAC,cAAc,GAAE,cAAqB,GAAG,aAAa,CAMzF;AAED,wBAAgB,sBAAsB,wBAErC;AAED,wBAAgB,oBAAoB,sBAGnC;AAED,wBAAgB,sBAAsB,4CAErC;AAED,wBAAgB,yBAAyB,2BAExC;AAED,wBAAgB,sBAAsB;kBAnEpB,MAAM,EAAE;EAqEzB;AAED,wBAAgB,uBAAuB,CAAC,cAAc,CAAC,EAAE,cAAc,wBAGtE;AAED,wBAAgB,4BAA4B,CACxC,cAAc,GAAE,cAAqB,GACtC,mBAAmB,GAAG,SAAS,CAsBjC;AAED,wBAAgB,4BAA4B,CAAC,cAAc,GAAE,cAAqB,yDAIjF;AAED,wBAAgB,iBAAiB,YAShC;AAED,wBAAgB,iCAAiC,+BAEhD;AAED,wBAAgB,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,WAEvD;AAED,wBAAgB,kBAAkB,YAEjC;AAED,wBAAgB,mBAAmB,YAGlC;AAED,wBAAgB,0BAA0B,YAEzC;AAED,wBAAgB,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,WAEvD;AAED,wBAAgB,YAAY,YAE3B;AAED,wBAAgB,oBAAoB,YAEnC;AAED,wBAAgB,cAAc,CAAC,cAAc,GAAE,cAAqB,WAEnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/get-configuration.ts"],"sourcesContent":["import { Config } from '@jest/types';\nimport { swcDir } from '@swc/cli';\nimport { ESLint } from 'eslint';\nimport fs from 'fs';\nimport path from 'path';\nimport { LinterOptions } from 'stylelint';\nimport { ViteUserConfig } from 'vitest/config';\nimport { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';\n\nimport { ReviewConfiguration } from '../cli/commands/review';\nimport { log } from './log';\nimport { getFolders } from './get-folders';\nimport { readJson, readJsonSafe } from './read-json';\n\nexport const allowedWebpackDevServerOptions = ['headers', 'port', 'proxy', 'static'] as const;\n\ntype ElementType<T> = T extends readonly (infer ElementType)[] ? ElementType : never;\n\nexport interface MinifyJSOptions {\n compress?: boolean;\n mangle?: boolean;\n}\n\nexport interface MinifyCssOptions {}\n\nexport interface MinifyOptions {\n css?: boolean | MinifyCssOptions;\n js?: boolean | MinifyJSOptions;\n}\n\nexport interface WebpackConfiguration\n extends Omit<\n Pick<WebpackDevServerConfiguration, ElementType<typeof allowedWebpackDevServerOptions>>,\n 'proxy'\n > {\n 'contentBase'?: boolean | string | string[] | number; // deprecated 2024-07\n 'custom-style-rules'?: boolean;\n 'expose-shared-dependencies'?: boolean;\n 'devServer'?: false | WebpackDevServerConfiguration;\n 'disable-style-check'?: boolean;\n 'minify'?: MinifyOptions;\n 'proxy'?: WebpackDevServerConfiguration['proxy'] | string;\n}\n\nexport interface ESLintConfiguration extends ESLint.Options {\n disabled?: boolean;\n}\n\nexport interface StylelintConfiguration extends Partial<LinterOptions> {\n ignorePattern?: string[];\n disabled?: boolean;\n}\n\nexport type JestConfiguration = Omit<Config.Argv, '_' | '$0'>;\n\nexport interface NodeConfiguration {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n NODE_OPTIONS?: string[];\n}\n\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum CommandName {\n 'build' = 'build',\n 'bundle-package' = 'bundle-package',\n 'clean' = 'clean',\n 'convert-eslint-config' = 'convert-eslint-config',\n 'eslint' = 'eslint',\n 'init' = 'init',\n 'install' = 'install',\n 'kendo-ui-license' = 'kendo-ui-license',\n 'lint' = 'lint',\n 'mfe-package-clean' = 'mfe-package-clean',\n 'mfe-package-publish' = 'mfe-package-publish',\n 'mfe-publish' = 'mfe-publish',\n 'prepare-package' = 'prepare-package',\n 'review' = 'review',\n 'start' = 'start',\n 'styles-check' = 'styles-check',\n 'test' = 'test',\n 'task' = 'task',\n 'upload-sourcemaps' = 'upload-sourcemaps',\n}\n/* eslint-enable @typescript-eslint/naming-convention */\n\nexport type VitestConfiguration = ViteUserConfig['test'];\n\nexport interface WebComponentBranchConfigs {\n publishTag?: string;\n uploadSourcemaps?: boolean;\n}\n\ninterface WebComponentOptions {\n legacyRoot?: boolean;\n /**\n * mapping of git branches to configs.\n * Used to separate configs (ex publish tag) depending on current branch\n */\n branches?: Record<string, WebComponentBranchConfigs>;\n}\n\ntype Configuration = {\n 'jest'?: JestConfiguration;\n 'legacy'?: boolean;\n 'lint'?: { eslint: ESLintConfiguration; stylelint: StylelintConfiguration };\n 'review'?: ReviewConfiguration;\n 'swc-compile-package'?: Parameters<typeof swcDir>[0];\n 'test'?: JestConfiguration; // for backward-compatibility\n 'testRunner'?: string;\n 'vitest'?: VitestConfiguration;\n 'web-component'?: boolean | string | WebComponentOptions;\n 'webpack'?: false | WebpackConfiguration;\n} & {\n [key in CommandName]?: NodeConfiguration;\n} & NodeConfiguration;\n\ntype LocationOrJson = string | Record<string, any>;\n\nexport function getConfiguration(locationOrJson: LocationOrJson = './'): Configuration {\n const json =\n typeof locationOrJson === 'string'\n ? readJson(path.join(locationOrJson, 'package.json'))\n : locationOrJson;\n return json?.cli ?? {};\n}\n\nexport function getConfigurationSafe(locationOrJson: LocationOrJson = './'): Configuration {\n const json =\n typeof locationOrJson === 'string'\n ? readJsonSafe(path.join(locationOrJson, 'package.json'))\n : locationOrJson;\n return json?.cli ?? {};\n}\n\nexport function getESLintConfiguration() {\n return getConfiguration().lint?.eslint ?? {};\n}\n\nexport function getJestConfiguration() {\n const configuration = getConfiguration();\n return configuration.jest ?? configuration.test ?? {};\n}\n\nexport function getReviewConfiguration() {\n return getConfiguration().review ?? {};\n}\n\nexport function getStylelintConfiguration() {\n return getConfiguration().lint?.stylelint ?? {};\n}\n\nexport function getVitestConfiguration() {\n return getConfiguration().vitest ?? {};\n}\n\nexport function getWebpackConfiguration(locationOrJson?: LocationOrJson) {\n const { webpack } = getConfiguration(locationOrJson);\n return typeof webpack === 'object' ? webpack : {};\n}\n\nexport function getWebComponentConfiguration(\n locationOrJson: LocationOrJson = './'\n): WebComponentOptions | undefined {\n const config = getConfigurationSafe(locationOrJson)['web-component'];\n\n if (config === true) {\n return {};\n }\n\n if (typeof config === 'object') {\n return config;\n }\n\n if (typeof config === 'string') {\n const configPath = path.resolve(\n typeof locationOrJson === 'string' ? path.join(locationOrJson, config) : config\n );\n if (fs.existsSync(configPath)) {\n return require(path.resolve(configPath));\n }\n log.warning(`could not find web-component configuration: \"${config}\"`);\n\n return undefined;\n }\n}\n\nexport function getWebComponentBranchConfigs(locationOrJson: LocationOrJson = './') {\n const config = getWebComponentConfiguration(locationOrJson);\n\n return config?.branches;\n}\n\nexport function hasHeadlessBundle() {\n let source: string;\n try {\n source = getFolders().source;\n } catch {\n return false;\n }\n const headlessPath = path.join(source, 'headless.ts');\n return fs.existsSync(headlessPath);\n}\n\nexport function getSwcCompilePackageConfiguration() {\n return getConfiguration()['swc-compile-package'] ?? {};\n}\n\nexport function isBundle(locationOrJson?: LocationOrJson) {\n return getConfiguration(locationOrJson).webpack !== false;\n}\n\nexport function isCustomStyleRules() {\n return getWebpackConfiguration()['custom-style-rules'] === true;\n}\n\nexport function isDevServerDisabled() {\n const webpackConfiguration = getWebpackConfiguration();\n return webpackConfiguration.devServer === false;\n}\n\nexport function isExposeSharedDependencies() {\n return getWebpackConfiguration()['expose-shared-dependencies'] === true;\n}\n\nexport function isLegacy(locationOrJson?: LocationOrJson) {\n return getConfiguration(locationOrJson).legacy === true;\n}\n\nexport function isLegacyRoot() {\n return getWebComponentConfiguration()?.legacyRoot === true;\n}\n\nexport function isStyleCheckDisabled() {\n return getWebpackConfiguration()['disable-style-check'] === true;\n}\n\nexport function isWebComponent(locationOrJson: LocationOrJson = './') {\n return !!getWebComponentConfiguration(locationOrJson);\n}\n"],"names":["CommandName","allowedWebpackDevServerOptions","getConfiguration","getConfigurationSafe","getESLintConfiguration","getJestConfiguration","getReviewConfiguration","getStylelintConfiguration","getSwcCompilePackageConfiguration","getVitestConfiguration","getWebComponentBranchConfigs","getWebComponentConfiguration","getWebpackConfiguration","hasHeadlessBundle","isBundle","isCustomStyleRules","isDevServerDisabled","isExposeSharedDependencies","isLegacy","isLegacyRoot","isStyleCheckDisabled","isWebComponent","locationOrJson","json","readJson","path","join","cli","readJsonSafe","lint","eslint","configuration","jest","test","review","stylelint","vitest","webpack","config","configPath","resolve","fs","existsSync","require","log","warning","undefined","branches","source","getFolders","headlessPath","webpackConfiguration","devServer","legacy","legacyRoot"],"mappings":";;;;;;;;;;;QA6DYA;eAAAA;;QA/CCC;eAAAA;;QAuGGC;eAAAA;;QAQAC;eAAAA;;QAQAC;eAAAA;;QAIAC;eAAAA;;QAKAC;eAAAA;;QAIAC;eAAAA;;QAwDAC;eAAAA;;QApDAC;eAAAA;;QAmCAC;eAAAA;;QA1BAC;eAAAA;;QALAC;eAAAA;;QAqCAC;eAAAA;;QAeAC;eAAAA;;QAIAC;eAAAA;;QAIAC;eAAAA;;QAKAC;eAAAA;;QAIAC;eAAAA;;QAIAC;eAAAA;;QAIAC;eAAAA;;QAIAC;eAAAA;;;2DAxOD;6DACE;qBAMG;4BACO;0BACY;;;;;;AAEhC,MAAMpB,iCAAiC;IAAC;IAAW;IAAQ;IAAS;CAAS;AA+C7E,IAAA,AAAKD,qCAAAA;;;;;;;;;;;;;;;;;;;;WAAAA;;AAwDL,SAASE,iBAAiBoB,iBAAiC,IAAI;IAClE,MAAMC,OACF,OAAOD,mBAAmB,WACpBE,IAAAA,kBAAQ,EAACC,aAAI,CAACC,IAAI,CAACJ,gBAAgB,mBACnCA;QACHC;IAAP,OAAOA,CAAAA,YAAAA,iBAAAA,2BAAAA,KAAMI,GAAG,cAATJ,uBAAA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,gCAAAA,4CAAAA,oDAAAA,8BAAgC2C,UAAU,MAAK;AAC1D;AAEO,SAASlC;IACZ,OAAOR,yBAAyB,CAAC,sBAAsB,KAAK;AAChE;AAEO,SAASS,eAAeC,iBAAiC,IAAI;IAChE,OAAO,CAAC,CAACX,6BAA6BW;AAC1C"}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/get-configuration.ts"],"sourcesContent":["import { Config } from '@jest/types';\nimport { swcDir } from '@swc/cli';\nimport { ESLint } from 'eslint';\nimport fs from 'fs';\nimport path from 'path';\nimport { LinterOptions } from 'stylelint';\nimport { ViteUserConfig } from 'vitest/config';\nimport { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';\n\nimport { ReviewConfiguration } from '../cli/commands/review';\nimport { log } from './log';\nimport { getFolders } from './get-folders';\nimport { readJson, readJsonSafe } from './read-json';\n\nexport const allowedWebpackDevServerOptions = ['headers', 'port', 'proxy', 'static'] as const;\n\ntype ElementType<T> = T extends readonly (infer ElementType)[] ? ElementType : never;\n\nexport interface MinifyJSOptions {\n compress?: boolean;\n mangle?: boolean;\n}\n\nexport interface MinifyCssOptions {}\n\nexport interface MinifyOptions {\n css?: boolean | MinifyCssOptions;\n js?: boolean | MinifyJSOptions;\n}\n\nexport interface WebpackConfiguration\n extends Omit<\n Pick<WebpackDevServerConfiguration, ElementType<typeof allowedWebpackDevServerOptions>>,\n 'proxy'\n > {\n 'contentBase'?: boolean | string | string[] | number; // deprecated 2024-07\n 'custom-style-rules'?: boolean;\n 'expose-shared-dependencies'?: boolean;\n 'devServer'?: false | WebpackDevServerConfiguration;\n 'disable-style-check'?: boolean;\n 'minify'?: MinifyOptions;\n 'proxy'?: WebpackDevServerConfiguration['proxy'] | string;\n}\n\nexport interface ESLintConfiguration extends ESLint.Options {\n disabled?: boolean;\n}\n\nexport interface StylelintConfiguration extends Partial<LinterOptions> {\n ignorePattern?: string[];\n disabled?: boolean;\n}\n\nexport interface JestConfiguration extends Omit<Config.Argv, '_' | '$0'> {\n omitDefault?: string[];\n}\n\nexport interface NodeConfiguration {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n NODE_OPTIONS?: string[];\n}\n\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum CommandName {\n 'build' = 'build',\n 'bundle-package' = 'bundle-package',\n 'clean' = 'clean',\n 'convert-eslint-config' = 'convert-eslint-config',\n 'eslint' = 'eslint',\n 'init' = 'init',\n 'install' = 'install',\n 'kendo-ui-license' = 'kendo-ui-license',\n 'lint' = 'lint',\n 'mfe-package-clean' = 'mfe-package-clean',\n 'mfe-package-publish' = 'mfe-package-publish',\n 'mfe-publish' = 'mfe-publish',\n 'prepare-package' = 'prepare-package',\n 'review' = 'review',\n 'start' = 'start',\n 'styles-check' = 'styles-check',\n 'test' = 'test',\n 'task' = 'task',\n 'upload-sourcemaps' = 'upload-sourcemaps',\n}\n/* eslint-enable @typescript-eslint/naming-convention */\n\nexport type VitestConfiguration = ViteUserConfig['test'] & {\n omitDefault?: string[];\n};\n\nexport interface WebComponentBranchConfigs {\n publishTag?: string;\n uploadSourcemaps?: boolean;\n}\n\ninterface WebComponentOptions {\n legacyRoot?: boolean;\n /**\n * mapping of git branches to configs.\n * Used to separate configs (ex publish tag) depending on current branch\n */\n branches?: Record<string, WebComponentBranchConfigs>;\n}\n\ntype Configuration = {\n 'jest'?: JestConfiguration;\n 'legacy'?: boolean;\n 'lint'?: { eslint: ESLintConfiguration; stylelint: StylelintConfiguration };\n 'review'?: ReviewConfiguration;\n 'swc-compile-package'?: Parameters<typeof swcDir>[0];\n 'test'?: JestConfiguration; // for backward-compatibility\n 'testRunner'?: string;\n 'vitest'?: VitestConfiguration;\n 'web-component'?: boolean | string | WebComponentOptions;\n 'webpack'?: false | WebpackConfiguration;\n} & {\n [key in CommandName]?: NodeConfiguration;\n} & NodeConfiguration;\n\ntype LocationOrJson = string | Record<string, any>;\n\nexport function getConfiguration(locationOrJson: LocationOrJson = './'): Configuration {\n const json =\n typeof locationOrJson === 'string'\n ? readJson(path.join(locationOrJson, 'package.json'))\n : locationOrJson;\n return json?.cli ?? {};\n}\n\nexport function getConfigurationSafe(locationOrJson: LocationOrJson = './'): Configuration {\n const json =\n typeof locationOrJson === 'string'\n ? readJsonSafe(path.join(locationOrJson, 'package.json'))\n : locationOrJson;\n return json?.cli ?? {};\n}\n\nexport function getESLintConfiguration() {\n return getConfiguration().lint?.eslint ?? {};\n}\n\nexport function getJestConfiguration() {\n const configuration = getConfiguration();\n return configuration.jest ?? configuration.test ?? {};\n}\n\nexport function getReviewConfiguration() {\n return getConfiguration().review ?? {};\n}\n\nexport function getStylelintConfiguration() {\n return getConfiguration().lint?.stylelint ?? {};\n}\n\nexport function getVitestConfiguration() {\n return getConfiguration().vitest ?? {};\n}\n\nexport function getWebpackConfiguration(locationOrJson?: LocationOrJson) {\n const { webpack } = getConfiguration(locationOrJson);\n return typeof webpack === 'object' ? webpack : {};\n}\n\nexport function getWebComponentConfiguration(\n locationOrJson: LocationOrJson = './'\n): WebComponentOptions | undefined {\n const config = getConfigurationSafe(locationOrJson)['web-component'];\n\n if (config === true) {\n return {};\n }\n\n if (typeof config === 'object') {\n return config;\n }\n\n if (typeof config === 'string') {\n const configPath = path.resolve(\n typeof locationOrJson === 'string' ? path.join(locationOrJson, config) : config\n );\n if (fs.existsSync(configPath)) {\n return require(path.resolve(configPath));\n }\n log.warning(`could not find web-component configuration: \"${config}\"`);\n\n return undefined;\n }\n}\n\nexport function getWebComponentBranchConfigs(locationOrJson: LocationOrJson = './') {\n const config = getWebComponentConfiguration(locationOrJson);\n\n return config?.branches;\n}\n\nexport function hasHeadlessBundle() {\n let source: string;\n try {\n source = getFolders().source;\n } catch {\n return false;\n }\n const headlessPath = path.join(source, 'headless.ts');\n return fs.existsSync(headlessPath);\n}\n\nexport function getSwcCompilePackageConfiguration() {\n return getConfiguration()['swc-compile-package'] ?? {};\n}\n\nexport function isBundle(locationOrJson?: LocationOrJson) {\n return getConfiguration(locationOrJson).webpack !== false;\n}\n\nexport function isCustomStyleRules() {\n return getWebpackConfiguration()['custom-style-rules'] === true;\n}\n\nexport function isDevServerDisabled() {\n const webpackConfiguration = getWebpackConfiguration();\n return webpackConfiguration.devServer === false;\n}\n\nexport function isExposeSharedDependencies() {\n return getWebpackConfiguration()['expose-shared-dependencies'] === true;\n}\n\nexport function isLegacy(locationOrJson?: LocationOrJson) {\n return getConfiguration(locationOrJson).legacy === true;\n}\n\nexport function isLegacyRoot() {\n return getWebComponentConfiguration()?.legacyRoot === true;\n}\n\nexport function isStyleCheckDisabled() {\n return getWebpackConfiguration()['disable-style-check'] === true;\n}\n\nexport function isWebComponent(locationOrJson: LocationOrJson = './') {\n return !!getWebComponentConfiguration(locationOrJson);\n}\n"],"names":["CommandName","allowedWebpackDevServerOptions","getConfiguration","getConfigurationSafe","getESLintConfiguration","getJestConfiguration","getReviewConfiguration","getStylelintConfiguration","getSwcCompilePackageConfiguration","getVitestConfiguration","getWebComponentBranchConfigs","getWebComponentConfiguration","getWebpackConfiguration","hasHeadlessBundle","isBundle","isCustomStyleRules","isDevServerDisabled","isExposeSharedDependencies","isLegacy","isLegacyRoot","isStyleCheckDisabled","isWebComponent","locationOrJson","json","readJson","path","join","cli","readJsonSafe","lint","eslint","configuration","jest","test","review","stylelint","vitest","webpack","config","configPath","resolve","fs","existsSync","require","log","warning","undefined","branches","source","getFolders","headlessPath","webpackConfiguration","devServer","legacy","legacyRoot"],"mappings":";;;;;;;;;;;QA+DYA;eAAAA;;QAjDCC;eAAAA;;QA2GGC;eAAAA;;QAQAC;eAAAA;;QAQAC;eAAAA;;QAIAC;eAAAA;;QAKAC;eAAAA;;QAIAC;eAAAA;;QAwDAC;eAAAA;;QApDAC;eAAAA;;QAmCAC;eAAAA;;QA1BAC;eAAAA;;QALAC;eAAAA;;QAqCAC;eAAAA;;QAeAC;eAAAA;;QAIAC;eAAAA;;QAIAC;eAAAA;;QAKAC;eAAAA;;QAIAC;eAAAA;;QAIAC;eAAAA;;QAIAC;eAAAA;;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Y,SAASQ,cAA+B;IACpD,OAAOpB,iBAAiBoB,gBAAgBe,OAAO,KAAK;AACxD;AAEO,SAAStB;IACZ,OAAOH,yBAAyB,CAAC,qBAAqB,KAAK;AAC/D;AAEO,SAASI;IACZ,MAAMmC,uBAAuBvC;IAC7B,OAAOuC,qBAAqBC,SAAS,KAAK;AAC9C;AAEO,SAASnC;IACZ,OAAOL,yBAAyB,CAAC,6BAA6B,KAAK;AACvE;AAEO,SAASM,SAASI,cAA+B;IACpD,OAAOpB,iBAAiBoB,gBAAgB+B,MAAM,KAAK;AACvD;AAEO,SAASlC;QACLR;IAAP,OAAOA,EAAAA,gCAAAA,4CAAAA,oDAAAA,8BAAgC2C,UAAU,MAAK;AAC1D;AAEO,SAASlC;IACZ,OAAOR,yBAAyB,CAAC,sBAAsB,KAAK;AAChE;AAEO,SAASS,eAAeC,iBAAiC,IAAI;IAChE,OAAO,CAAC,CAACX,6BAA6BW;AAC1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-jest-config.d.ts","sourceRoot":"","sources":["../../src/utils/get-jest-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"get-jest-config.d.ts","sourceRoot":"","sources":["../../src/utils/get-jest-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAiCrC;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAsB/D"}
|
|
@@ -12,12 +12,13 @@ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
|
12
12
|
const _getconfiguration = require("./get-configuration");
|
|
13
13
|
const _getdestinationfolders = require("./get-destination-folders");
|
|
14
14
|
const _toarray = require("./to-array");
|
|
15
|
+
const _omit = require("./omit");
|
|
15
16
|
function _interop_require_default(obj) {
|
|
16
17
|
return obj && obj.__esModule ? obj : {
|
|
17
18
|
default: obj
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
|
-
function getDefaultJestConfiguration(
|
|
21
|
+
function getDefaultJestConfiguration() {
|
|
21
22
|
const moduleNameMapper = {
|
|
22
23
|
'\\.(css|scss|less|png|svg|svg\\?\\w+|jpg|jpeg|gif|woff|woff2|eot|ttf|otf)$': 'identity-obj-proxy'
|
|
23
24
|
};
|
|
@@ -26,8 +27,7 @@ function getDefaultJestConfiguration({ coveragePathIgnorePatterns = [], setupFil
|
|
|
26
27
|
'**/*.{ts,tsx}'
|
|
27
28
|
],
|
|
28
29
|
coveragePathIgnorePatterns: [
|
|
29
|
-
'^.+\\.d\\.ts$'
|
|
30
|
-
...coveragePathIgnorePatterns
|
|
30
|
+
'^.+\\.d\\.ts$'
|
|
31
31
|
],
|
|
32
32
|
coverageReporters: [
|
|
33
33
|
'html-spa',
|
|
@@ -42,14 +42,12 @@ function getDefaultJestConfiguration({ coveragePathIgnorePatterns = [], setupFil
|
|
|
42
42
|
],
|
|
43
43
|
preset: _path.default.join(__dirname, '../../jest'),
|
|
44
44
|
setupFiles: [
|
|
45
|
-
_path.default.join(__dirname, '../../jest/setup.js')
|
|
46
|
-
...(0, _toarray.toArray)(setupFiles)
|
|
45
|
+
_path.default.join(__dirname, '../../jest/setup.js')
|
|
47
46
|
],
|
|
48
47
|
testEnvironment: 'jsdom',
|
|
49
48
|
testPathIgnorePatterns: [
|
|
50
49
|
'\\.yalc',
|
|
51
|
-
...(0, _getdestinationfolders.getDestinationFolders)()
|
|
52
|
-
...(0, _toarray.toArray)(testPathIgnorePatterns)
|
|
50
|
+
...(0, _getdestinationfolders.getDestinationFolders)()
|
|
53
51
|
],
|
|
54
52
|
testRunner: 'jest-circus/runner',
|
|
55
53
|
transformIgnorePatterns: [
|
|
@@ -59,12 +57,13 @@ function getDefaultJestConfiguration({ coveragePathIgnorePatterns = [], setupFil
|
|
|
59
57
|
};
|
|
60
58
|
}
|
|
61
59
|
function getJestConfigCLI(args) {
|
|
62
|
-
const { coveragePathIgnorePatterns, setupFiles, testPathIgnorePatterns, ...config } = {
|
|
60
|
+
const { coveragePathIgnorePatterns, omitDefault = [], setupFiles, testPathIgnorePatterns, ...config } = {
|
|
63
61
|
...(0, _getconfiguration.getJestConfiguration)(),
|
|
64
62
|
...args
|
|
65
63
|
};
|
|
64
|
+
const defaultConfig = (0, _omit.omit)(getDefaultJestConfiguration(), omitDefault);
|
|
66
65
|
return stringifyForCLI({
|
|
67
|
-
...
|
|
66
|
+
...mergeArrayValues(defaultConfig, {
|
|
68
67
|
coveragePathIgnorePatterns,
|
|
69
68
|
setupFiles,
|
|
70
69
|
testPathIgnorePatterns
|
|
@@ -72,6 +71,18 @@ function getJestConfigCLI(args) {
|
|
|
72
71
|
...config
|
|
73
72
|
});
|
|
74
73
|
}
|
|
74
|
+
function mergeArrayValues(config, arrayValues) {
|
|
75
|
+
return Object.keys(arrayValues).reduce((result, key)=>{
|
|
76
|
+
const newValue = arrayValues[key];
|
|
77
|
+
if (newValue) {
|
|
78
|
+
result[key] = [
|
|
79
|
+
...(0, _toarray.toArray)(result[key]),
|
|
80
|
+
...(0, _toarray.toArray)(newValue)
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}, config);
|
|
85
|
+
}
|
|
75
86
|
function stringifyForCLI(config) {
|
|
76
87
|
return [
|
|
77
88
|
'collectCoverageFrom',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/get-jest-config.ts"],"sourcesContent":["import { Config } from '@jest/types';\nimport path from 'path';\nimport { getJestConfiguration } from './get-configuration';\nimport { getDestinationFolders } from './get-destination-folders';\nimport { toArray } from './to-array';\
|
|
1
|
+
{"version":3,"sources":["../../src/utils/get-jest-config.ts"],"sourcesContent":["import { Config } from '@jest/types';\nimport path from 'path';\nimport { getJestConfiguration } from './get-configuration';\nimport { getDestinationFolders } from './get-destination-folders';\nimport { toArray } from './to-array';\nimport { omit } from './omit';\n\nfunction getDefaultJestConfiguration() {\n const moduleNameMapper = {\n '\\\\.(css|scss|less|png|svg|svg\\\\?\\\\w+|jpg|jpeg|gif|woff|woff2|eot|ttf|otf)$':\n 'identity-obj-proxy',\n };\n\n return {\n collectCoverageFrom: ['**/*.{ts,tsx}'],\n coveragePathIgnorePatterns: ['^.+\\\\.d\\\\.ts$'],\n coverageReporters: ['html-spa', 'text', 'json', 'cobertura', 'lcov'],\n moduleNameMapper,\n modulePathIgnorePatterns: ['<rootDir>/.*/__mocks__'],\n preset: path.join(__dirname, '../../jest'),\n setupFiles: [path.join(__dirname, '../../jest/setup.js')],\n testEnvironment: 'jsdom',\n testPathIgnorePatterns: ['\\\\.yalc', ...getDestinationFolders()],\n testRunner: 'jest-circus/runner',\n transformIgnorePatterns: ['node_modules/(?!(@servicetitan|@react-hook|nanoid|axios)/)'],\n verbose: true,\n } as Omit<Config.Argv, 'collectCoverageFrom' | 'moduleNameMapper' | 'setupFiles'> & {\n collectCoverageFrom: string[];\n moduleNameMapper: Record<string, string>;\n setupFiles: string[];\n };\n}\n\n/**\n * Get Jest config for running it using jest CLI (see jest runCLI function)\n */\nexport function getJestConfigCLI(args: Config.Argv): Config.Argv {\n const {\n coveragePathIgnorePatterns,\n omitDefault = [],\n setupFiles,\n testPathIgnorePatterns,\n ...config\n } = {\n ...getJestConfiguration(),\n ...args,\n };\n\n const defaultConfig = omit(getDefaultJestConfiguration(), omitDefault);\n\n return stringifyForCLI({\n ...mergeArrayValues(defaultConfig, {\n coveragePathIgnorePatterns,\n setupFiles,\n testPathIgnorePatterns,\n }),\n ...config,\n });\n}\n\nfunction mergeArrayValues(\n config: any,\n arrayValues: {\n coveragePathIgnorePatterns?: string | string[];\n setupFiles?: string | string[];\n testPathIgnorePatterns?: string | string[];\n }\n) {\n return Object.keys(arrayValues).reduce((result, key: keyof typeof arrayValues) => {\n const newValue = arrayValues[key];\n if (newValue) {\n result[key] = [...toArray(result[key]), ...toArray(newValue)];\n }\n return result;\n }, config);\n}\n\nfunction stringifyForCLI(config: any): Config.Argv {\n return ['collectCoverageFrom', 'globals', 'moduleNameMapper', 'transform'].reduce(\n (result, key) => {\n const value = result[key];\n if (value && typeof value !== 'string') {\n result[key] = JSON.stringify(result[key]);\n }\n return result;\n },\n config\n );\n}\n"],"names":["getJestConfigCLI","getDefaultJestConfiguration","moduleNameMapper","collectCoverageFrom","coveragePathIgnorePatterns","coverageReporters","modulePathIgnorePatterns","preset","path","join","__dirname","setupFiles","testEnvironment","testPathIgnorePatterns","getDestinationFolders","testRunner","transformIgnorePatterns","verbose","args","omitDefault","config","getJestConfiguration","defaultConfig","omit","stringifyForCLI","mergeArrayValues","arrayValues","Object","keys","reduce","result","key","newValue","toArray","value","JSON","stringify"],"mappings":";;;;+BAoCgBA;;;eAAAA;;;6DAnCC;kCACoB;uCACC;yBACd;sBACH;;;;;;AAErB,SAASC;IACL,MAAMC,mBAAmB;QACrB,8EACI;IACR;IAEA,OAAO;QACHC,qBAAqB;YAAC;SAAgB;QACtCC,4BAA4B;YAAC;SAAgB;QAC7CC,mBAAmB;YAAC;YAAY;YAAQ;YAAQ;YAAa;SAAO;QACpEH;QACAI,0BAA0B;YAAC;SAAyB;QACpDC,QAAQC,aAAI,CAACC,IAAI,CAACC,WAAW;QAC7BC,YAAY;YAACH,aAAI,CAACC,IAAI,CAACC,WAAW;SAAuB;QACzDE,iBAAiB;QACjBC,wBAAwB;YAAC;eAAcC,IAAAA,4CAAqB;SAAG;QAC/DC,YAAY;QACZC,yBAAyB;YAAC;SAA6D;QACvFC,SAAS;IACb;AAKJ;AAKO,SAASjB,iBAAiBkB,IAAiB;IAC9C,MAAM,EACFd,0BAA0B,EAC1Be,cAAc,EAAE,EAChBR,UAAU,EACVE,sBAAsB,EACtB,GAAGO,QACN,GAAG;QACA,GAAGC,IAAAA,sCAAoB,GAAE;QACzB,GAAGH,IAAI;IACX;IAEA,MAAMI,gBAAgBC,IAAAA,UAAI,EAACtB,+BAA+BkB;IAE1D,OAAOK,gBAAgB;QACnB,GAAGC,iBAAiBH,eAAe;YAC/BlB;YACAO;YACAE;QACJ,EAAE;QACF,GAAGO,MAAM;IACb;AACJ;AAEA,SAASK,iBACLL,MAAW,EACXM,WAIC;IAED,OAAOC,OAAOC,IAAI,CAACF,aAAaG,MAAM,CAAC,CAACC,QAAQC;QAC5C,MAAMC,WAAWN,WAAW,CAACK,IAAI;QACjC,IAAIC,UAAU;YACVF,MAAM,CAACC,IAAI,GAAG;mBAAIE,IAAAA,gBAAO,EAACH,MAAM,CAACC,IAAI;mBAAME,IAAAA,gBAAO,EAACD;aAAU;QACjE;QACA,OAAOF;IACX,GAAGV;AACP;AAEA,SAASI,gBAAgBJ,MAAW;IAChC,OAAO;QAAC;QAAuB;QAAW;QAAoB;KAAY,CAACS,MAAM,CAC7E,CAACC,QAAQC;QACL,MAAMG,QAAQJ,MAAM,CAACC,IAAI;QACzB,IAAIG,SAAS,OAAOA,UAAU,UAAU;YACpCJ,MAAM,CAACC,IAAI,GAAGI,KAAKC,SAAS,CAACN,MAAM,CAACC,IAAI;QAC5C;QACA,OAAOD;IACX,GACAV;AAER"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -18,6 +18,7 @@ _export_star(require("./get-tsconfig"), exports);
|
|
|
18
18
|
_export_star(require("./load-shared-dependencies"), exports);
|
|
19
19
|
_export_star(require("./log"), exports);
|
|
20
20
|
_export_star(require("./log-errors"), exports);
|
|
21
|
+
_export_star(require("./omit"), exports);
|
|
21
22
|
_export_star(require("./pick"), exports);
|
|
22
23
|
_export_star(require("./read-json"), exports);
|
|
23
24
|
_export_star(require("./to-array"), exports);
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './find-packages';\nexport * from './find-up';\nexport * from './format-duration';\nexport * from './get-branch-configs';\nexport * from './get-configuration';\nexport * from './get-destination-folders';\nexport * from './get-folders';\nexport * from './get-jest-config';\nexport * from './get-package-data';\nexport * from './get-package-name';\nexport * from './get-packages';\nexport * from './get-startup-version';\nexport * from './get-tsconfig';\nexport * from './load-shared-dependencies';\nexport * from './log';\nexport * from './log-errors';\nexport * from './pick';\nexport * from './read-json';\nexport * from './to-array';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './find-packages';\nexport * from './find-up';\nexport * from './format-duration';\nexport * from './get-branch-configs';\nexport * from './get-configuration';\nexport * from './get-destination-folders';\nexport * from './get-folders';\nexport * from './get-jest-config';\nexport * from './get-package-data';\nexport * from './get-package-name';\nexport * from './get-packages';\nexport * from './get-startup-version';\nexport * from './get-tsconfig';\nexport * from './load-shared-dependencies';\nexport * from './log';\nexport * from './log-errors';\nexport * from './omit';\nexport * from './pick';\nexport * from './read-json';\nexport * from './to-array';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omit.d.ts","sourceRoot":"","sources":["../../src/utils/omit.ts"],"names":[],"mappings":"AAAA,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAE7E"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "omit", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return omit;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function omit(obj, keys) {
|
|
12
|
+
return keys.reduce((result, key)=>omitInternal({
|
|
13
|
+
...result
|
|
14
|
+
}, key.split('.')), obj);
|
|
15
|
+
}
|
|
16
|
+
function omitInternal(obj, [key, ...rest]) {
|
|
17
|
+
if (!rest.length) {
|
|
18
|
+
delete obj[key];
|
|
19
|
+
} else if (typeof obj[key] === 'object') {
|
|
20
|
+
return {
|
|
21
|
+
...obj,
|
|
22
|
+
[key]: omitInternal(obj[key], rest)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return obj;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=omit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/omit.ts"],"sourcesContent":["export function omit<T extends Record<string, any>>(obj: T, keys: string[]): T {\n return keys.reduce((result, key) => omitInternal({ ...result }, key.split('.')), obj);\n}\n\nfunction omitInternal<T extends Record<string, any>>(obj: T, [key, ...rest]: string[]): T {\n if (!rest.length) {\n delete obj[key];\n } else if (typeof obj[key] === 'object') {\n return { ...obj, [key]: omitInternal(obj[key], rest) };\n }\n return obj;\n}\n"],"names":["omit","obj","keys","reduce","result","key","omitInternal","split","rest","length"],"mappings":";;;;+BAAgBA;;;eAAAA;;;AAAT,SAASA,KAAoCC,GAAM,EAAEC,IAAc;IACtE,OAAOA,KAAKC,MAAM,CAAC,CAACC,QAAQC,MAAQC,aAAa;YAAE,GAAGF,MAAM;QAAC,GAAGC,IAAIE,KAAK,CAAC,OAAON;AACrF;AAEA,SAASK,aAA4CL,GAAM,EAAE,CAACI,KAAK,GAAGG,KAAe;IACjF,IAAI,CAACA,KAAKC,MAAM,EAAE;QACd,OAAOR,GAAG,CAACI,IAAI;IACnB,OAAO,IAAI,OAAOJ,GAAG,CAACI,IAAI,KAAK,UAAU;QACrC,OAAO;YAAE,GAAGJ,GAAG;YAAE,CAACI,IAAI,EAAEC,aAAaL,GAAG,CAACI,IAAI,EAAEG;QAAM;IACzD;IACA,OAAOP;AACX"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/startup",
|
|
3
|
-
"version": "32.
|
|
3
|
+
"version": "32.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://docs.st.dev/docs/frontend/startup",
|
|
6
6
|
"repository": {
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"@jest/core": "~29.7.0",
|
|
38
38
|
"@jest/types": "~29.6.3",
|
|
39
39
|
"@jsdevtools/coverage-istanbul-loader": "^3.0.5",
|
|
40
|
-
"@servicetitan/eslint-config": "32.
|
|
41
|
-
"@servicetitan/stylelint-config": "32.
|
|
40
|
+
"@servicetitan/eslint-config": "32.2.0",
|
|
41
|
+
"@servicetitan/stylelint-config": "32.2.0",
|
|
42
42
|
"@svgr/webpack": "^8.1.0",
|
|
43
43
|
"@swc/cli": "^0.5.0",
|
|
44
44
|
"@swc/core": "1.13.5",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"debounce": "^2.2.0",
|
|
53
53
|
"debug": "^4.4.3",
|
|
54
54
|
"deepmerge": "~4.3.1",
|
|
55
|
-
"eslint": "~9.
|
|
55
|
+
"eslint": "~9.37.0",
|
|
56
56
|
"execa": "~5.1.1",
|
|
57
57
|
"glob": "~11.0.3",
|
|
58
58
|
"html-webpack-plugin": "~5.6.4",
|
|
@@ -63,33 +63,34 @@
|
|
|
63
63
|
"jest-environment-jsdom": "^29.7.0",
|
|
64
64
|
"jest-fetch-mock": "~3.0.3",
|
|
65
65
|
"json5": "^2.2.3",
|
|
66
|
-
"
|
|
67
|
-
"
|
|
66
|
+
"jwa": "^1.4.2",
|
|
67
|
+
"lerna": "~9.0.0",
|
|
68
|
+
"less": "~4.4.2",
|
|
68
69
|
"less-loader": "~12.3.0",
|
|
69
70
|
"less-plugin-npm-import": "~2.1.0",
|
|
70
71
|
"lodash.memoize": "^4.1.2",
|
|
71
|
-
"memfs": "~4.
|
|
72
|
+
"memfs": "~4.49.0",
|
|
72
73
|
"mini-css-extract-plugin": "~2.9.4",
|
|
73
74
|
"moment-locales-webpack-plugin": "~1.2.0",
|
|
74
75
|
"multimatch": "~5.0.0",
|
|
75
76
|
"portfinder": "~1.0.38",
|
|
76
77
|
"postcss": "~8.5.6",
|
|
77
78
|
"prettier": "~3.6.2",
|
|
78
|
-
"sass": "~1.
|
|
79
|
+
"sass": "~1.93.2",
|
|
79
80
|
"sass-loader": "~16.0.5",
|
|
80
|
-
"semver": "~7.7.
|
|
81
|
+
"semver": "~7.7.3",
|
|
81
82
|
"source-map-loader": "~5.0.0",
|
|
82
83
|
"style-loader": "~4.0.0",
|
|
83
|
-
"stylelint": "~16.
|
|
84
|
-
"terminal-link": "^
|
|
84
|
+
"stylelint": "~16.25.0",
|
|
85
|
+
"terminal-link": "^5.0.0",
|
|
85
86
|
"terser-webpack-plugin": "^5.3.14",
|
|
86
|
-
"ts-jest": "29.4.
|
|
87
|
+
"ts-jest": "29.4.5",
|
|
87
88
|
"ts-node": "~10.9.2",
|
|
88
89
|
"typed-css-modules": "~0.9.1",
|
|
89
|
-
"typescript": "5.9.
|
|
90
|
+
"typescript": "5.9.3",
|
|
90
91
|
"vitest": "^3.2.4",
|
|
91
|
-
"webpack": "~5.
|
|
92
|
-
"webpack-assets-manifest": "~6.
|
|
92
|
+
"webpack": "~5.102.1",
|
|
93
|
+
"webpack-assets-manifest": "~6.3.0",
|
|
93
94
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
94
95
|
"webpack-dev-server": "~5.2.2",
|
|
95
96
|
"webpack-filter-warnings-plugin": "~1.2.1",
|
|
@@ -101,7 +102,7 @@
|
|
|
101
102
|
"yargs": "~17.7.2"
|
|
102
103
|
},
|
|
103
104
|
"peerDependencies": {
|
|
104
|
-
"moment": "
|
|
105
|
+
"moment": ">=2.30.1"
|
|
105
106
|
},
|
|
106
107
|
"peerDependenciesMeta": {
|
|
107
108
|
"moment": {
|
|
@@ -112,6 +113,10 @@
|
|
|
112
113
|
"@swc/cli": [
|
|
113
114
|
"Update when https://github.com/swc-project/swc/issues/10535 is resolved",
|
|
114
115
|
"See also SwcCompilePackage.execute in file://./src/cli/tasks/swc-compile-package.ts"
|
|
116
|
+
],
|
|
117
|
+
"jwa": [
|
|
118
|
+
"@progress/kendo-licensing@1.3.5 -> jsonwebtoken@9.0.2 -> jws@3.2.2 -> jwa@1.4.1",
|
|
119
|
+
"Forcing ^1.4.2 to fix Node v25 incompatibility in 1.4.1 (see https://github.com/auth0/node-jsonwebtoken/issues/992)"
|
|
115
120
|
]
|
|
116
121
|
},
|
|
117
122
|
"publishConfig": {
|
|
@@ -120,5 +125,5 @@
|
|
|
120
125
|
"cli": {
|
|
121
126
|
"webpack": false
|
|
122
127
|
},
|
|
123
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "76a83fea33e04809b97c72720751878b1e3002d7"
|
|
124
129
|
}
|
|
@@ -66,6 +66,10 @@ describe(`[startup] Test ${Vitest.name}`, () => {
|
|
|
66
66
|
expect(vitest.close).toHaveBeenCalled();
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
+
function expectCallsVitestWithConfig(config: Record<string, any>) {
|
|
70
|
+
expect(startVitest).toHaveBeenCalledWith('test', [], {}, { test: config });
|
|
71
|
+
}
|
|
72
|
+
|
|
69
73
|
describe('with package.json config', () => {
|
|
70
74
|
const packageJSONConfig: ViteUserConfig['test'] = { bail: 1, globals: false };
|
|
71
75
|
|
|
@@ -78,19 +82,40 @@ describe(`[startup] Test ${Vitest.name}`, () => {
|
|
|
78
82
|
test('merges package.json config with default config', async () => {
|
|
79
83
|
await subject();
|
|
80
84
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
expectCallsVitestWithConfig({ ...defaultConfig, ...packageJSONConfig });
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe('with omitDefault', () => {
|
|
89
|
+
beforeEach(() => {
|
|
90
|
+
vol.fromJSON({
|
|
91
|
+
'package.json': JSON.stringify({
|
|
92
|
+
cli: {
|
|
93
|
+
vitest: {
|
|
94
|
+
...packageJSONConfig,
|
|
95
|
+
omitDefault: ['coverage.include', 'environment'],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
}),
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('omits specified defaults', async () => {
|
|
103
|
+
await subject();
|
|
104
|
+
|
|
105
|
+
const { environment, coverage, ...restDefault } = defaultConfig;
|
|
106
|
+
const { include, ...restCoverage } = coverage as any;
|
|
107
|
+
const defaultSansOmitted = { coverage: restCoverage, ...restDefault };
|
|
108
|
+
|
|
109
|
+
expectCallsVitestWithConfig({ ...defaultSansOmitted, ...packageJSONConfig });
|
|
110
|
+
});
|
|
87
111
|
});
|
|
88
112
|
});
|
|
89
113
|
|
|
90
114
|
describe('with vite test config', () => {
|
|
91
|
-
|
|
115
|
+
let viteTestConfig: NonNullable<ViteUserConfig['test']>;
|
|
92
116
|
|
|
93
117
|
beforeEach(() => {
|
|
118
|
+
viteTestConfig = { name: 'foo', watch: false };
|
|
94
119
|
jest.mocked(resolveConfig).mockResolvedValue({
|
|
95
120
|
viteConfig: { test: viteTestConfig },
|
|
96
121
|
} as any);
|
|
@@ -99,13 +124,57 @@ describe(`[startup] Test ${Vitest.name}`, () => {
|
|
|
99
124
|
test('merges vite test config with default config', async () => {
|
|
100
125
|
await subject();
|
|
101
126
|
|
|
102
|
-
|
|
103
|
-
'test',
|
|
104
|
-
[],
|
|
105
|
-
{},
|
|
106
|
-
{ test: { ...defaultConfig, ...viteTestConfig } }
|
|
107
|
-
);
|
|
127
|
+
expectCallsVitestWithConfig({ ...defaultConfig, ...viteTestConfig });
|
|
108
128
|
});
|
|
129
|
+
|
|
130
|
+
describe('with "coverage.include"', () => {
|
|
131
|
+
const defaultCoverageInclude = (defaultConfig.coverage as any).include;
|
|
132
|
+
const include = ['packages/foo'];
|
|
133
|
+
|
|
134
|
+
beforeEach(() => {
|
|
135
|
+
Object.assign(viteTestConfig, {
|
|
136
|
+
coverage: { include },
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('merges default and custom "coverage.include"', async () => {
|
|
141
|
+
await subject();
|
|
142
|
+
|
|
143
|
+
expectCallsVitestWithConfig(
|
|
144
|
+
expect.objectContaining({
|
|
145
|
+
coverage: {
|
|
146
|
+
...defaultConfig.coverage,
|
|
147
|
+
include: [...defaultCoverageInclude, ...include],
|
|
148
|
+
},
|
|
149
|
+
})
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
describe('when omitDefault contains "coverage.include"', () => {
|
|
154
|
+
beforeEach(() => {
|
|
155
|
+
vol.fromJSON({
|
|
156
|
+
'package.json': JSON.stringify({
|
|
157
|
+
cli: { vitest: { omitDefault: ['coverage.include'] } },
|
|
158
|
+
}),
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test('omits default "coverage.include"', async () => {
|
|
163
|
+
await subject();
|
|
164
|
+
|
|
165
|
+
expectCallsVitestWithConfig(
|
|
166
|
+
expect.objectContaining({
|
|
167
|
+
coverage: {
|
|
168
|
+
...defaultConfig.coverage,
|
|
169
|
+
include,
|
|
170
|
+
},
|
|
171
|
+
})
|
|
172
|
+
);
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test('can use omitDefault to replace coverage.include', () => {});
|
|
109
178
|
});
|
|
110
179
|
|
|
111
180
|
describe('with command line options', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { configDefaults, coverageConfigDefaults, mergeConfig, ViteUserConfig } from 'vitest/config';
|
|
2
2
|
import { startVitest, parseCLI, resolveConfig } from 'vitest/node';
|
|
3
|
-
import { getVitestConfiguration, log } from '../../../../utils';
|
|
3
|
+
import { getVitestConfiguration, log, omit } from '../../../../utils';
|
|
4
4
|
|
|
5
5
|
type VitestConfig = NonNullable<ViteUserConfig['test']>;
|
|
6
6
|
|
|
@@ -58,8 +58,10 @@ function getDefaultConfig(): VitestConfig {
|
|
|
58
58
|
async function getUserConfig(): Promise<ViteUserConfig> {
|
|
59
59
|
const { viteConfig } = await resolveConfig();
|
|
60
60
|
|
|
61
|
+
const { omitDefault = [], ...config } = getVitestConfiguration();
|
|
62
|
+
|
|
61
63
|
const result = mergeConfig(
|
|
62
|
-
mergeConfig(getDefaultConfig(),
|
|
64
|
+
mergeConfig(omit(getDefaultConfig(), omitDefault), config),
|
|
63
65
|
viteConfig.test ?? {}
|
|
64
66
|
);
|
|
65
67
|
|
|
@@ -36,7 +36,7 @@ describe(`[startup] Utils`, () => {
|
|
|
36
36
|
test('creates .git folder', () => {
|
|
37
37
|
subject();
|
|
38
38
|
|
|
39
|
-
expect(mkdirSpy).toHaveBeenCalledWith('.git');
|
|
39
|
+
expect(mkdirSpy).toHaveBeenCalledWith('.git', { recursive: true });
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
describe('when command is Init', () => {
|
package/src/cli/utils/bundle.ts
CHANGED
|
@@ -19,6 +19,11 @@ export function maybeCreateGitFolder(command: Newable<Command>) {
|
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
if (!fs.existsSync('.git')) {
|
|
22
|
-
|
|
22
|
+
/*
|
|
23
|
+
* Using {recursive: true} to ignore if directory exists. This happens
|
|
24
|
+
* when parallel process creates the directory after we've checked
|
|
25
|
+
* whether it exists.
|
|
26
|
+
*/
|
|
27
|
+
fs.mkdirSync('.git', { recursive: true });
|
|
23
28
|
}
|
|
24
29
|
}
|
|
@@ -2,6 +2,7 @@ import { Config } from '@jest/types';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { getJestConfiguration } from '../get-configuration';
|
|
4
4
|
import { getDestinationFolders } from '../get-destination-folders';
|
|
5
|
+
import { pick } from '../pick';
|
|
5
6
|
|
|
6
7
|
import { getJestConfigCLI } from '../get-jest-config';
|
|
7
8
|
|
|
@@ -76,5 +77,48 @@ describe('[startup] Utils', () => {
|
|
|
76
77
|
expect.objectContaining({ transform: JSON.stringify(transform) })
|
|
77
78
|
);
|
|
78
79
|
});
|
|
80
|
+
|
|
81
|
+
describe('with "omitDefault"', () => {
|
|
82
|
+
beforeEach(() => {
|
|
83
|
+
jest.mocked(getJestConfiguration).mockReturnValue({
|
|
84
|
+
omitDefault: Object.keys(defaultConfig),
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('omits specified defaults', () => {
|
|
89
|
+
expect(pick(subject(), getJestConfiguration().omitDefault!)).toEqual({});
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe.each(['coveragePathIgnorePatterns', 'setupFiles', 'testPathIgnorePatterns'])(
|
|
94
|
+
'with custom "%s"',
|
|
95
|
+
key => {
|
|
96
|
+
let customConfig: Record<string, string[]>;
|
|
97
|
+
|
|
98
|
+
beforeEach(() => {
|
|
99
|
+
customConfig = { [key]: ['foo'] };
|
|
100
|
+
jest.mocked(getJestConfiguration).mockReturnValue(customConfig);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('appends custom value to default', () => {
|
|
104
|
+
expect(subject()).toEqual(
|
|
105
|
+
expect.objectContaining({
|
|
106
|
+
[key]: [
|
|
107
|
+
...defaultConfig[key],
|
|
108
|
+
...(getJestConfiguration()[key] as string[]),
|
|
109
|
+
],
|
|
110
|
+
})
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe('when default is omitted', () => {
|
|
115
|
+
beforeEach(() => (customConfig.omitDefault = [key]));
|
|
116
|
+
|
|
117
|
+
test('returns only custom value', () => {
|
|
118
|
+
expect(subject()[key]).toEqual(customConfig[key]);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
);
|
|
79
123
|
});
|
|
80
124
|
});
|
|
@@ -51,7 +51,9 @@ export interface StylelintConfiguration extends Partial<LinterOptions> {
|
|
|
51
51
|
disabled?: boolean;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export
|
|
54
|
+
export interface JestConfiguration extends Omit<Config.Argv, '_' | '$0'> {
|
|
55
|
+
omitDefault?: string[];
|
|
56
|
+
}
|
|
55
57
|
|
|
56
58
|
export interface NodeConfiguration {
|
|
57
59
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -82,7 +84,9 @@ export enum CommandName {
|
|
|
82
84
|
}
|
|
83
85
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
84
86
|
|
|
85
|
-
export type VitestConfiguration = ViteUserConfig['test']
|
|
87
|
+
export type VitestConfiguration = ViteUserConfig['test'] & {
|
|
88
|
+
omitDefault?: string[];
|
|
89
|
+
};
|
|
86
90
|
|
|
87
91
|
export interface WebComponentBranchConfigs {
|
|
88
92
|
publishTag?: string;
|
|
@@ -3,16 +3,9 @@ import path from 'path';
|
|
|
3
3
|
import { getJestConfiguration } from './get-configuration';
|
|
4
4
|
import { getDestinationFolders } from './get-destination-folders';
|
|
5
5
|
import { toArray } from './to-array';
|
|
6
|
+
import { omit } from './omit';
|
|
6
7
|
|
|
7
|
-
function getDefaultJestConfiguration({
|
|
8
|
-
coveragePathIgnorePatterns = [],
|
|
9
|
-
setupFiles = [],
|
|
10
|
-
testPathIgnorePatterns = [],
|
|
11
|
-
}: {
|
|
12
|
-
coveragePathIgnorePatterns?: string[];
|
|
13
|
-
setupFiles?: string[];
|
|
14
|
-
testPathIgnorePatterns?: string[];
|
|
15
|
-
}) {
|
|
8
|
+
function getDefaultJestConfiguration() {
|
|
16
9
|
const moduleNameMapper = {
|
|
17
10
|
'\\.(css|scss|less|png|svg|svg\\?\\w+|jpg|jpeg|gif|woff|woff2|eot|ttf|otf)$':
|
|
18
11
|
'identity-obj-proxy',
|
|
@@ -20,21 +13,21 @@ function getDefaultJestConfiguration({
|
|
|
20
13
|
|
|
21
14
|
return {
|
|
22
15
|
collectCoverageFrom: ['**/*.{ts,tsx}'],
|
|
23
|
-
coveragePathIgnorePatterns: ['^.+\\.d\\.ts$'
|
|
16
|
+
coveragePathIgnorePatterns: ['^.+\\.d\\.ts$'],
|
|
24
17
|
coverageReporters: ['html-spa', 'text', 'json', 'cobertura', 'lcov'],
|
|
25
18
|
moduleNameMapper,
|
|
26
19
|
modulePathIgnorePatterns: ['<rootDir>/.*/__mocks__'],
|
|
27
20
|
preset: path.join(__dirname, '../../jest'),
|
|
28
|
-
setupFiles: [path.join(__dirname, '../../jest/setup.js')
|
|
21
|
+
setupFiles: [path.join(__dirname, '../../jest/setup.js')],
|
|
29
22
|
testEnvironment: 'jsdom',
|
|
30
|
-
testPathIgnorePatterns: [
|
|
31
|
-
'\\.yalc',
|
|
32
|
-
...getDestinationFolders(),
|
|
33
|
-
...toArray(testPathIgnorePatterns),
|
|
34
|
-
],
|
|
23
|
+
testPathIgnorePatterns: ['\\.yalc', ...getDestinationFolders()],
|
|
35
24
|
testRunner: 'jest-circus/runner',
|
|
36
25
|
transformIgnorePatterns: ['node_modules/(?!(@servicetitan|@react-hook|nanoid|axios)/)'],
|
|
37
26
|
verbose: true,
|
|
27
|
+
} as Omit<Config.Argv, 'collectCoverageFrom' | 'moduleNameMapper' | 'setupFiles'> & {
|
|
28
|
+
collectCoverageFrom: string[];
|
|
29
|
+
moduleNameMapper: Record<string, string>;
|
|
30
|
+
setupFiles: string[];
|
|
38
31
|
};
|
|
39
32
|
}
|
|
40
33
|
|
|
@@ -42,13 +35,21 @@ function getDefaultJestConfiguration({
|
|
|
42
35
|
* Get Jest config for running it using jest CLI (see jest runCLI function)
|
|
43
36
|
*/
|
|
44
37
|
export function getJestConfigCLI(args: Config.Argv): Config.Argv {
|
|
45
|
-
const {
|
|
38
|
+
const {
|
|
39
|
+
coveragePathIgnorePatterns,
|
|
40
|
+
omitDefault = [],
|
|
41
|
+
setupFiles,
|
|
42
|
+
testPathIgnorePatterns,
|
|
43
|
+
...config
|
|
44
|
+
} = {
|
|
46
45
|
...getJestConfiguration(),
|
|
47
46
|
...args,
|
|
48
47
|
};
|
|
49
48
|
|
|
49
|
+
const defaultConfig = omit(getDefaultJestConfiguration(), omitDefault);
|
|
50
|
+
|
|
50
51
|
return stringifyForCLI({
|
|
51
|
-
...
|
|
52
|
+
...mergeArrayValues(defaultConfig, {
|
|
52
53
|
coveragePathIgnorePatterns,
|
|
53
54
|
setupFiles,
|
|
54
55
|
testPathIgnorePatterns,
|
|
@@ -57,6 +58,23 @@ export function getJestConfigCLI(args: Config.Argv): Config.Argv {
|
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
function mergeArrayValues(
|
|
62
|
+
config: any,
|
|
63
|
+
arrayValues: {
|
|
64
|
+
coveragePathIgnorePatterns?: string | string[];
|
|
65
|
+
setupFiles?: string | string[];
|
|
66
|
+
testPathIgnorePatterns?: string | string[];
|
|
67
|
+
}
|
|
68
|
+
) {
|
|
69
|
+
return Object.keys(arrayValues).reduce((result, key: keyof typeof arrayValues) => {
|
|
70
|
+
const newValue = arrayValues[key];
|
|
71
|
+
if (newValue) {
|
|
72
|
+
result[key] = [...toArray(result[key]), ...toArray(newValue)];
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}, config);
|
|
76
|
+
}
|
|
77
|
+
|
|
60
78
|
function stringifyForCLI(config: any): Config.Argv {
|
|
61
79
|
return ['collectCoverageFrom', 'globals', 'moduleNameMapper', 'transform'].reduce(
|
|
62
80
|
(result, key) => {
|
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function omit<T extends Record<string, any>>(obj: T, keys: string[]): T {
|
|
2
|
+
return keys.reduce((result, key) => omitInternal({ ...result }, key.split('.')), obj);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function omitInternal<T extends Record<string, any>>(obj: T, [key, ...rest]: string[]): T {
|
|
6
|
+
if (!rest.length) {
|
|
7
|
+
delete obj[key];
|
|
8
|
+
} else if (typeof obj[key] === 'object') {
|
|
9
|
+
return { ...obj, [key]: omitInternal(obj[key], rest) };
|
|
10
|
+
}
|
|
11
|
+
return obj;
|
|
12
|
+
}
|