@storm-software/workspace-tools 1.19.2 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +1 -1
- package/index.js +300 -212
- package/meta.json +1 -1
- package/package.json +1 -1
- package/src/base/index.js +83 -19
- package/src/executors/tsup/executor.js +6827 -103
- package/src/executors/tsup/schema.d.ts +3 -3
- package/src/executors/tsup-neutral/executor.js +1511 -1591
- package/src/executors/tsup-neutral/schema.d.ts +2 -1
- package/src/executors/tsup-node/executor.js +112 -59
- package/src/executors/tsup-node/schema.d.ts +4 -1
- package/src/generators/config-schema/generator.js +60 -15
- package/src/generators/node-library/generator.js +60 -3
- package/src/generators/preset/generator.js +60 -3
- package/src/utils/index.js +46 -6
package/package.json
CHANGED
package/src/base/index.js
CHANGED
|
@@ -6755,20 +6755,19 @@ var getWorkspaceRoot2 = () => {
|
|
|
6755
6755
|
};
|
|
6756
6756
|
|
|
6757
6757
|
// packages/workspace-tools/src/utils/apply-workspace-tokens.ts
|
|
6758
|
-
var
|
|
6758
|
+
var applyWorkspaceExecutorTokens = (option, config) => {
|
|
6759
6759
|
let result = option;
|
|
6760
6760
|
if (!result) {
|
|
6761
6761
|
return result;
|
|
6762
6762
|
}
|
|
6763
|
-
const workspaceRoot = getWorkspaceRoot2();
|
|
6764
6763
|
let projectName;
|
|
6765
6764
|
let projectRoot;
|
|
6766
6765
|
let sourceRoot;
|
|
6767
|
-
if (config?.
|
|
6766
|
+
if (config?.projectName) {
|
|
6768
6767
|
const context = config;
|
|
6769
6768
|
projectName = context.projectName;
|
|
6770
|
-
projectRoot = context.
|
|
6771
|
-
sourceRoot = context.
|
|
6769
|
+
projectRoot = context.root;
|
|
6770
|
+
sourceRoot = context.sourceRoot;
|
|
6772
6771
|
} else {
|
|
6773
6772
|
const projectConfig = config;
|
|
6774
6773
|
projectName = projectConfig.name;
|
|
@@ -6785,27 +6784,80 @@ var applyWorkspaceTokens = (option, config) => {
|
|
|
6785
6784
|
result = result.replaceAll("{sourceRoot}", sourceRoot);
|
|
6786
6785
|
}
|
|
6787
6786
|
if (result.includes("{workspaceRoot}")) {
|
|
6788
|
-
result = result.replaceAll(
|
|
6787
|
+
result = result.replaceAll(
|
|
6788
|
+
"{workspaceRoot}",
|
|
6789
|
+
config.workspaceRoot ?? getWorkspaceRoot2()
|
|
6790
|
+
);
|
|
6791
|
+
}
|
|
6792
|
+
return result;
|
|
6793
|
+
};
|
|
6794
|
+
var applyWorkspaceGeneratorTokens = (option, config) => {
|
|
6795
|
+
let result = option;
|
|
6796
|
+
if (!result) {
|
|
6797
|
+
return result;
|
|
6798
|
+
}
|
|
6799
|
+
if (result.includes("{workspaceRoot}")) {
|
|
6800
|
+
result = result.replaceAll(
|
|
6801
|
+
"{workspaceRoot}",
|
|
6802
|
+
config.workspaceRoot ?? getWorkspaceRoot2()
|
|
6803
|
+
);
|
|
6789
6804
|
}
|
|
6790
6805
|
return result;
|
|
6791
6806
|
};
|
|
6807
|
+
var applyWorkspaceTokens = (options, config, tokenizerFn) => {
|
|
6808
|
+
let result = options;
|
|
6809
|
+
if (!result) {
|
|
6810
|
+
return {};
|
|
6811
|
+
}
|
|
6812
|
+
return Object.keys(options).reduce(
|
|
6813
|
+
(ret, option) => {
|
|
6814
|
+
if (options[option] === void 0 || options[option] === null || typeof options[option] === "number" || typeof options[option] === "boolean" || typeof options[option] === "string") {
|
|
6815
|
+
ret[option] = tokenizerFn(option, config);
|
|
6816
|
+
} else if (Array.isArray(options[option])) {
|
|
6817
|
+
ret[option] = options[option].map(
|
|
6818
|
+
(item) => tokenizerFn(item, config)
|
|
6819
|
+
);
|
|
6820
|
+
} else if (typeof options[option] === "object") {
|
|
6821
|
+
ret[option] = tokenizerFn(options[option], config);
|
|
6822
|
+
}
|
|
6823
|
+
return ret;
|
|
6824
|
+
},
|
|
6825
|
+
{}
|
|
6826
|
+
);
|
|
6827
|
+
};
|
|
6792
6828
|
|
|
6793
6829
|
// packages/workspace-tools/src/base/base-executor.ts
|
|
6794
|
-
var withRunExecutor = (name, executorFn, executorOptions = {
|
|
6830
|
+
var withRunExecutor = (name, executorFn, executorOptions = {
|
|
6831
|
+
skipReadingConfig: false
|
|
6832
|
+
}) => async (options, context) => {
|
|
6795
6833
|
const startTime = Date.now();
|
|
6796
6834
|
try {
|
|
6797
6835
|
console.info(`\u26A1 Running the ${name} executor...`);
|
|
6798
|
-
|
|
6836
|
+
if (executorOptions?.applyDefaultFn) {
|
|
6837
|
+
options = executorOptions.applyDefaultFn(options);
|
|
6838
|
+
}
|
|
6839
|
+
console.debug(`\u2699\uFE0F Executor schema options:
|
|
6799
6840
|
`, options);
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
6841
|
+
if (!context.projectsConfigurations?.projects || !context.projectName || !context.projectsConfigurations.projects[context.projectName]) {
|
|
6842
|
+
throw new Error(
|
|
6843
|
+
"The Build process failed because the context is not valid. Please run this command from a workspace."
|
|
6844
|
+
);
|
|
6845
|
+
}
|
|
6846
|
+
const workspaceRoot = getWorkspaceRoot2();
|
|
6847
|
+
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
6848
|
+
const sourceRoot = context.projectsConfigurations.projects[context.projectName].sourceRoot;
|
|
6849
|
+
const projectName = context.projectsConfigurations.projects[context.projectName].name;
|
|
6850
|
+
const tokenized = applyWorkspaceTokens(
|
|
6851
|
+
options,
|
|
6852
|
+
{
|
|
6853
|
+
workspaceRoot,
|
|
6854
|
+
projectRoot,
|
|
6855
|
+
sourceRoot,
|
|
6856
|
+
projectName,
|
|
6857
|
+
...context.projectsConfigurations.projects[context.projectName],
|
|
6858
|
+
...executorOptions
|
|
6807
6859
|
},
|
|
6808
|
-
|
|
6860
|
+
applyWorkspaceExecutorTokens
|
|
6809
6861
|
);
|
|
6810
6862
|
let config;
|
|
6811
6863
|
if (!executorOptions.skipReadingConfig) {
|
|
@@ -6843,11 +6895,21 @@ ${Object.keys(process.env).map((key) => ` - ${key}=${process.env[key]}`).join("\
|
|
|
6843
6895
|
};
|
|
6844
6896
|
|
|
6845
6897
|
// packages/workspace-tools/src/base/base-generator.ts
|
|
6846
|
-
var withRunGenerator = (name, generatorFn, generatorOptions = {
|
|
6898
|
+
var withRunGenerator = (name, generatorFn, generatorOptions = {
|
|
6899
|
+
skipReadingConfig: false
|
|
6900
|
+
}) => async (tree, options) => {
|
|
6847
6901
|
const startTime = Date.now();
|
|
6848
6902
|
try {
|
|
6849
6903
|
console.info(`\u26A1 Running the ${name} generator...`);
|
|
6850
|
-
|
|
6904
|
+
if (generatorOptions?.applyDefaultFn) {
|
|
6905
|
+
options = generatorOptions.applyDefaultFn(options);
|
|
6906
|
+
}
|
|
6907
|
+
console.debug("\u2699\uFE0F Generator schema options: \n", options);
|
|
6908
|
+
const tokenized = applyWorkspaceTokens(
|
|
6909
|
+
options,
|
|
6910
|
+
{ workspaceRoot: tree.root },
|
|
6911
|
+
applyWorkspaceGeneratorTokens
|
|
6912
|
+
);
|
|
6851
6913
|
let config;
|
|
6852
6914
|
if (!generatorOptions.skipReadingConfig) {
|
|
6853
6915
|
const configFile = await getConfigFile();
|
|
@@ -6860,7 +6922,9 @@ var withRunGenerator = (name, generatorFn, generatorOptions = { skipReadingConfi
|
|
|
6860
6922
|
console.debug(`Loaded Storm config into env:
|
|
6861
6923
|
${Object.keys(process.env).map((key) => ` - ${key}=${process.env[key]}`).join("\n")}`);
|
|
6862
6924
|
}
|
|
6863
|
-
const result = await Promise.resolve(
|
|
6925
|
+
const result = await Promise.resolve(
|
|
6926
|
+
generatorFn(tree, tokenized, config)
|
|
6927
|
+
);
|
|
6864
6928
|
if (result && (!result.success || result.error && result?.error?.message && typeof result?.error?.message === "string" && result?.error?.name && typeof result?.error?.name === "string")) {
|
|
6865
6929
|
throw new Error(`The ${name} generator failed to run`, {
|
|
6866
6930
|
cause: result.error
|