@xylabs/ts-scripts-yarn3 7.0.0-rc.9 → 7.0.1
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/actions/build.mjs +87 -39
- package/dist/actions/build.mjs.map +1 -1
- package/dist/actions/clean-docs.mjs +22 -8
- package/dist/actions/clean-docs.mjs.map +1 -1
- package/dist/actions/clean-eslint.mjs +11 -5
- package/dist/actions/clean-eslint.mjs.map +1 -1
- package/dist/actions/clean-jest.mjs +29 -16
- package/dist/actions/clean-jest.mjs.map +1 -1
- package/dist/actions/clean.mjs +63 -32
- package/dist/actions/clean.mjs.map +1 -1
- package/dist/actions/compile.mjs +76 -50
- package/dist/actions/compile.mjs.map +1 -1
- package/dist/actions/copy-assets.mjs +38 -23
- package/dist/actions/copy-assets.mjs.map +1 -1
- package/dist/actions/cycle.mjs +57 -28
- package/dist/actions/cycle.mjs.map +1 -1
- package/dist/actions/dead.mjs +31 -16
- package/dist/actions/dead.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/checkPackage.mjs +84 -50
- package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs +7 -7
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +6 -10
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs +5 -5
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs +4 -0
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/index.mjs +84 -50
- package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
- package/dist/actions/deplint/deplint.mjs +120 -81
- package/dist/actions/deplint/deplint.mjs.map +1 -1
- package/dist/actions/deplint/findFiles.mjs +20 -4
- package/dist/actions/deplint/findFiles.mjs.map +1 -1
- package/dist/actions/deplint/findFilesByGlob.mjs +8 -1
- package/dist/actions/deplint/findFilesByGlob.mjs.map +1 -1
- package/dist/actions/deplint/getBasePackageName.mjs +4 -0
- package/dist/actions/deplint/getBasePackageName.mjs.map +1 -1
- package/dist/actions/deplint/getDependenciesFromPackageJson.mjs +4 -0
- package/dist/actions/deplint/getDependenciesFromPackageJson.mjs.map +1 -1
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs +24 -12
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs.map +1 -1
- package/dist/actions/deplint/getImportsFromFile.mjs +16 -9
- package/dist/actions/deplint/getImportsFromFile.mjs.map +1 -1
- package/dist/actions/deplint/index.mjs +120 -81
- package/dist/actions/deplint/index.mjs.map +1 -1
- package/dist/actions/deploy-major.mjs +57 -26
- package/dist/actions/deploy-major.mjs.map +1 -1
- package/dist/actions/deploy-minor.mjs +57 -26
- package/dist/actions/deploy-minor.mjs.map +1 -1
- package/dist/actions/deploy-next.mjs +57 -26
- package/dist/actions/deploy-next.mjs.map +1 -1
- package/dist/actions/deploy.mjs +57 -26
- package/dist/actions/deploy.mjs.map +1 -1
- package/dist/actions/dupdeps.mjs +37 -26
- package/dist/actions/dupdeps.mjs.map +1 -1
- package/dist/actions/fix.mjs +54 -36
- package/dist/actions/fix.mjs.map +1 -1
- package/dist/actions/gen-docs.mjs +65 -25
- package/dist/actions/gen-docs.mjs.map +1 -1
- package/dist/actions/gitignore-gen.mjs +44 -28
- package/dist/actions/gitignore-gen.mjs.map +1 -1
- package/dist/actions/gitlint-fix.mjs +14 -5
- package/dist/actions/gitlint-fix.mjs.map +1 -1
- package/dist/actions/gitlint.mjs +7 -4
- package/dist/actions/gitlint.mjs.map +1 -1
- package/dist/actions/index.mjs +1555 -966
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/knip.mjs +31 -16
- package/dist/actions/knip.mjs.map +1 -1
- package/dist/actions/license.mjs +51 -37
- package/dist/actions/license.mjs.map +1 -1
- package/dist/actions/lint.mjs +48 -33
- package/dist/actions/lint.mjs.map +1 -1
- package/dist/actions/npmignore-gen.mjs +44 -28
- package/dist/actions/npmignore-gen.mjs.map +1 -1
- package/dist/actions/package/clean-outputs.mjs +16 -6
- package/dist/actions/package/clean-outputs.mjs.map +1 -1
- package/dist/actions/package/clean-typescript.mjs +16 -6
- package/dist/actions/package/clean-typescript.mjs.map +1 -1
- package/dist/actions/package/clean.mjs +29 -12
- package/dist/actions/package/clean.mjs.map +1 -1
- package/dist/actions/package/compile/buildEntries.mjs +36 -8
- package/dist/actions/package/compile/buildEntries.mjs.map +1 -1
- package/dist/actions/package/compile/compile.mjs +341 -185
- package/dist/actions/package/compile/compile.mjs.map +1 -1
- package/dist/actions/package/compile/copyTypeFiles.mjs +23 -20
- package/dist/actions/package/compile/copyTypeFiles.mjs.map +1 -1
- package/dist/actions/package/compile/deepMerge.mjs +5 -0
- package/dist/actions/package/compile/deepMerge.mjs.map +1 -1
- package/dist/actions/package/compile/getCompilerOptions.mjs +9 -23
- package/dist/actions/package/compile/getCompilerOptions.mjs.map +1 -1
- package/dist/actions/package/compile/index.mjs +341 -267
- package/dist/actions/package/compile/index.mjs.map +1 -1
- package/dist/actions/package/compile/inputs.mjs +26 -3
- package/dist/actions/package/compile/inputs.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTsc.mjs +57 -96
- package/dist/actions/package/compile/packageCompileTsc.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTscTypes.mjs +94 -25
- package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTsup.mjs +321 -123
- package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -1
- package/dist/actions/package/copy-assets.mjs +21 -12
- package/dist/actions/package/copy-assets.mjs.map +1 -1
- package/dist/actions/package/cycle.mjs +16 -9
- package/dist/actions/package/cycle.mjs.map +1 -1
- package/dist/actions/package/gen-docs.mjs +13 -12
- package/dist/actions/package/gen-docs.mjs.map +1 -1
- package/dist/actions/package/index.mjs +507 -347
- package/dist/actions/package/index.mjs.map +1 -1
- package/dist/actions/package/lint.mjs +39 -16
- package/dist/actions/package/lint.mjs.map +1 -1
- package/dist/actions/package/publint.mjs +9 -6
- package/dist/actions/package/publint.mjs.map +1 -1
- package/dist/actions/package/recompile.mjs +371 -201
- package/dist/actions/package/recompile.mjs.map +1 -1
- package/dist/actions/publint.mjs +71 -37
- package/dist/actions/publint.mjs.map +1 -1
- package/dist/actions/rebuild.mjs +29 -17
- package/dist/actions/rebuild.mjs.map +1 -1
- package/dist/actions/recompile.mjs +67 -50
- package/dist/actions/recompile.mjs.map +1 -1
- package/dist/actions/reinstall.mjs +43 -25
- package/dist/actions/reinstall.mjs.map +1 -1
- package/dist/actions/relint.mjs +63 -40
- package/dist/actions/relint.mjs.map +1 -1
- package/dist/actions/retest.mjs +35 -17
- package/dist/actions/retest.mjs.map +1 -1
- package/dist/actions/sonar.mjs +32 -16
- package/dist/actions/sonar.mjs.map +1 -1
- package/dist/actions/statics.mjs +46 -27
- package/dist/actions/statics.mjs.map +1 -1
- package/dist/actions/test.mjs +30 -16
- package/dist/actions/test.mjs.map +1 -1
- package/dist/actions/up.mjs +27 -16
- package/dist/actions/up.mjs.map +1 -1
- package/dist/actions/updo.mjs +33 -18
- package/dist/actions/updo.mjs.map +1 -1
- package/dist/actions/upplug.mjs +53 -19
- package/dist/actions/upplug.mjs.map +1 -1
- package/dist/actions/upyarn.mjs +31 -16
- package/dist/actions/upyarn.mjs.map +1 -1
- package/dist/actions/yarn3only.mjs +23 -12
- package/dist/actions/yarn3only.mjs.map +1 -1
- package/dist/bin/package/build-only.mjs +346 -191
- package/dist/bin/package/build-only.mjs.map +1 -1
- package/dist/bin/package/build.mjs +348 -191
- package/dist/bin/package/build.mjs.map +1 -1
- package/dist/bin/package/clean-outputs.mjs +15 -6
- package/dist/bin/package/clean-outputs.mjs.map +1 -1
- package/dist/bin/package/clean-typescript.mjs +15 -6
- package/dist/bin/package/clean-typescript.mjs.map +1 -1
- package/dist/bin/package/clean.mjs +28 -12
- package/dist/bin/package/clean.mjs.map +1 -1
- package/dist/bin/package/compile-only.mjs +345 -190
- package/dist/bin/package/compile-only.mjs.map +1 -1
- package/dist/bin/package/compile-tsup.mjs +323 -126
- package/dist/bin/package/compile-tsup.mjs.map +1 -1
- package/dist/bin/package/compile.mjs +346 -191
- package/dist/bin/package/compile.mjs.map +1 -1
- package/dist/bin/package/copy-assets-cjs.mjs +23 -13
- package/dist/bin/package/copy-assets-cjs.mjs.map +1 -1
- package/dist/bin/package/copy-assets-esm.mjs +23 -13
- package/dist/bin/package/copy-assets-esm.mjs.map +1 -1
- package/dist/bin/package/cycle.mjs +17 -11
- package/dist/bin/package/cycle.mjs.map +1 -1
- package/dist/bin/package/fix.mjs +38 -16
- package/dist/bin/package/fix.mjs.map +1 -1
- package/dist/bin/package/gen-docs.mjs +12 -12
- package/dist/bin/package/gen-docs.mjs.map +1 -1
- package/dist/bin/package/lint.mjs +38 -16
- package/dist/bin/package/lint.mjs.map +1 -1
- package/dist/bin/package/publint.mjs +8 -6
- package/dist/bin/package/publint.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +372 -203
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/bin/package/relint.mjs +38 -16
- package/dist/bin/package/relint.mjs.map +1 -1
- package/dist/bin/xy.mjs +1351 -1075
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +133 -121
- package/dist/index.mjs +1908 -1460
- package/dist/index.mjs.map +1 -1
- package/dist/lib/checkResult.mjs +5 -2
- package/dist/lib/checkResult.mjs.map +1 -1
- package/dist/lib/createBuildConfig.mjs +24 -9
- package/dist/lib/createBuildConfig.mjs.map +1 -1
- package/dist/lib/defaultBuildConfig.mjs +6 -2
- package/dist/lib/defaultBuildConfig.mjs.map +1 -1
- package/dist/lib/deleteGlob.mjs +9 -3
- package/dist/lib/deleteGlob.mjs.map +1 -1
- package/dist/lib/dependencies/DuplicateDetector.mjs +23 -12
- package/dist/lib/dependencies/DuplicateDetector.mjs.map +1 -1
- package/dist/lib/dependencies/detectDuplicateDependencies.mjs +33 -22
- package/dist/lib/dependencies/detectDuplicateDependencies.mjs.map +1 -1
- package/dist/lib/dependencies/index.mjs +33 -22
- package/dist/lib/dependencies/index.mjs.map +1 -1
- package/dist/lib/file/ReadFileSyncOptions.mjs +3 -1
- package/dist/lib/file/ReadFileSyncOptions.mjs.map +1 -1
- package/dist/lib/file/constants.mjs.map +1 -1
- package/dist/lib/file/fileLines.mjs +13 -12
- package/dist/lib/file/fileLines.mjs.map +1 -1
- package/dist/lib/file/index.mjs +15 -14
- package/dist/lib/file/index.mjs.map +1 -1
- package/dist/lib/file/tryReadFileSync.mjs +8 -3
- package/dist/lib/file/tryReadFileSync.mjs.map +1 -1
- package/dist/lib/generateIgnoreFiles.mjs +43 -27
- package/dist/lib/generateIgnoreFiles.mjs.map +1 -1
- package/dist/lib/index.mjs +166 -106
- package/dist/lib/index.mjs.map +1 -1
- package/dist/lib/jsonFormatters.mjs +5 -2
- package/dist/lib/jsonFormatters.mjs.map +1 -1
- package/dist/lib/loadConfig.mjs +20 -10
- package/dist/lib/loadConfig.mjs.map +1 -1
- package/dist/lib/parsedPackageJSON.mjs +5 -2
- package/dist/lib/parsedPackageJSON.mjs.map +1 -1
- package/dist/lib/processEx.mjs +9 -6
- package/dist/lib/processEx.mjs.map +1 -1
- package/dist/lib/runSteps.mjs +19 -13
- package/dist/lib/runSteps.mjs.map +1 -1
- package/dist/lib/runStepsAsync.mjs +22 -22
- package/dist/lib/runStepsAsync.mjs.map +1 -1
- package/dist/lib/runXy.mjs +31 -19
- package/dist/lib/runXy.mjs.map +1 -1
- package/dist/lib/runXyWithWarning.mjs +5 -2
- package/dist/lib/runXyWithWarning.mjs.map +1 -1
- package/dist/lib/safeExit.mjs +13 -10
- package/dist/lib/safeExit.mjs.map +1 -1
- package/dist/lib/string/empty.mjs +5 -2
- package/dist/lib/string/empty.mjs.map +1 -1
- package/dist/lib/string/index.mjs +9 -3
- package/dist/lib/string/index.mjs.map +1 -1
- package/dist/lib/string/union.mjs +7 -1
- package/dist/lib/string/union.mjs.map +1 -1
- package/dist/lib/withErrnoException.mjs +7 -4
- package/dist/lib/withErrnoException.mjs.map +1 -1
- package/dist/lib/withError.mjs +5 -2
- package/dist/lib/withError.mjs.map +1 -1
- package/dist/lib/yarn/index.mjs +30 -11
- package/dist/lib/yarn/index.mjs.map +1 -1
- package/dist/lib/yarn/isYarnVersionOrGreater.mjs +15 -4
- package/dist/lib/yarn/isYarnVersionOrGreater.mjs.map +1 -1
- package/dist/lib/yarn/workspace/index.mjs +16 -5
- package/dist/lib/yarn/workspace/index.mjs.map +1 -1
- package/dist/lib/yarn/workspace/yarnWorkspace.mjs +16 -5
- package/dist/lib/yarn/workspace/yarnWorkspace.mjs.map +1 -1
- package/dist/lib/yarn/workspace/yarnWorkspaces.mjs +14 -3
- package/dist/lib/yarn/workspace/yarnWorkspaces.mjs.map +1 -1
- package/dist/lib/yarn/yarnInitCwd.mjs +5 -2
- package/dist/lib/yarn/yarnInitCwd.mjs.map +1 -1
- package/dist/loadPackageConfig.mjs +8 -3
- package/dist/loadPackageConfig.mjs.map +1 -1
- package/dist/xy/index.mjs +1351 -1074
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/param.mjs +9 -3
- package/dist/xy/param.mjs.map +1 -1
- package/dist/xy/xy.mjs +1351 -1074
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyBuildCommands.mjs +324 -305
- package/dist/xy/xyBuildCommands.mjs.map +1 -1
- package/dist/xy/xyCommonCommands.mjs +336 -251
- package/dist/xy/xyCommonCommands.mjs.map +1 -1
- package/dist/xy/xyDeployCommands.mjs +161 -99
- package/dist/xy/xyDeployCommands.mjs.map +1 -1
- package/dist/xy/xyInstallCommands.mjs +193 -145
- package/dist/xy/xyInstallCommands.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +437 -321
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/dist/xy/xyParseOptions.mjs +5 -2
- package/dist/xy/xyParseOptions.mjs.map +1 -1
- package/package.json +13 -12
- package/dist/actions/compile-types.mjs +0 -153
- package/dist/actions/compile-types.mjs.map +0 -1
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
1
4
|
// src/actions/package/clean-outputs.ts
|
|
2
5
|
import path from "path";
|
|
3
6
|
import chalk2 from "chalk";
|
|
@@ -5,12 +8,15 @@ import chalk2 from "chalk";
|
|
|
5
8
|
// src/lib/deleteGlob.ts
|
|
6
9
|
import fs from "fs";
|
|
7
10
|
import { glob } from "glob";
|
|
8
|
-
var deleteGlob = (globPath) => {
|
|
11
|
+
var deleteGlob = /* @__PURE__ */ __name((globPath) => {
|
|
9
12
|
const files = glob.sync(globPath);
|
|
10
13
|
for (const file of files) {
|
|
11
|
-
fs.rmSync(file, {
|
|
14
|
+
fs.rmSync(file, {
|
|
15
|
+
recursive: true,
|
|
16
|
+
force: true
|
|
17
|
+
});
|
|
12
18
|
}
|
|
13
|
-
};
|
|
19
|
+
}, "deleteGlob");
|
|
14
20
|
|
|
15
21
|
// src/lib/loadConfig.ts
|
|
16
22
|
import chalk from "chalk";
|
|
@@ -18,116 +24,114 @@ import { cosmiconfig } from "cosmiconfig";
|
|
|
18
24
|
import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
|
|
19
25
|
import deepmerge from "deepmerge";
|
|
20
26
|
var config;
|
|
21
|
-
var loadConfig = async (params) => {
|
|
22
|
-
if (config) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
var loadConfig = /* @__PURE__ */ __name(async (params) => {
|
|
28
|
+
if (config === void 0) {
|
|
29
|
+
const cosmicConfigResult = await cosmiconfig("xy", {
|
|
30
|
+
cache: true,
|
|
31
|
+
loaders: {
|
|
32
|
+
".ts": TypeScriptLoader()
|
|
33
|
+
}
|
|
34
|
+
}).search();
|
|
35
|
+
config = cosmicConfigResult?.config;
|
|
36
|
+
const configFilePath = cosmicConfigResult?.filepath;
|
|
37
|
+
if (configFilePath !== void 0) {
|
|
38
|
+
console.log(chalk.green(`Loaded config from ${configFilePath}`));
|
|
39
|
+
if (config.verbose) {
|
|
40
|
+
console.log(chalk.gray(`${JSON.stringify(config, null, 2)}`));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
30
43
|
}
|
|
31
44
|
return deepmerge(config, params ?? {});
|
|
32
|
-
};
|
|
45
|
+
}, "loadConfig");
|
|
33
46
|
|
|
34
47
|
// src/actions/package/clean-outputs.ts
|
|
35
|
-
var packageCleanOutputs = () => {
|
|
48
|
+
var packageCleanOutputs = /* @__PURE__ */ __name(() => {
|
|
36
49
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
37
50
|
const pkgName = process.env.npm_package_name;
|
|
38
|
-
const folders = [
|
|
51
|
+
const folders = [
|
|
52
|
+
path.join(pkg, "dist"),
|
|
53
|
+
path.join(pkg, "build"),
|
|
54
|
+
path.join(pkg, "docs")
|
|
55
|
+
];
|
|
39
56
|
console.log(chalk2.green(`Cleaning Outputs [${pkgName}]`));
|
|
40
57
|
for (let folder of folders) {
|
|
41
58
|
deleteGlob(folder);
|
|
42
59
|
}
|
|
43
60
|
return 0;
|
|
44
|
-
};
|
|
61
|
+
}, "packageCleanOutputs");
|
|
45
62
|
|
|
46
63
|
// src/actions/package/clean-typescript.ts
|
|
47
64
|
import path2 from "path";
|
|
48
65
|
import chalk3 from "chalk";
|
|
49
|
-
var packageCleanTypescript = () => {
|
|
66
|
+
var packageCleanTypescript = /* @__PURE__ */ __name(() => {
|
|
50
67
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
51
68
|
const pkgName = process.env.npm_package_name;
|
|
52
69
|
console.log(chalk3.green(`Cleaning Typescript [${pkgName}]`));
|
|
53
|
-
const files = [
|
|
70
|
+
const files = [
|
|
71
|
+
path2.join(pkg, "*.tsbuildinfo"),
|
|
72
|
+
path2.join(pkg, ".tsconfig.*"),
|
|
73
|
+
path2.join(pkg, ".eslintcache")
|
|
74
|
+
];
|
|
54
75
|
for (let file of files) {
|
|
55
76
|
deleteGlob(file);
|
|
56
77
|
}
|
|
57
78
|
return 0;
|
|
58
|
-
};
|
|
79
|
+
}, "packageCleanTypescript");
|
|
59
80
|
|
|
60
81
|
// src/actions/package/clean.ts
|
|
61
|
-
var packageClean = async () => {
|
|
62
|
-
return (await Promise.all([
|
|
63
|
-
|
|
82
|
+
var packageClean = /* @__PURE__ */ __name(async () => {
|
|
83
|
+
return (await Promise.all([
|
|
84
|
+
packageCleanOutputs(),
|
|
85
|
+
packageCleanTypescript()
|
|
86
|
+
])).reduce((prev, value) => prev + value, 0);
|
|
87
|
+
}, "packageClean");
|
|
64
88
|
|
|
65
89
|
// src/actions/package/compile/compile.ts
|
|
66
|
-
import
|
|
67
|
-
|
|
68
|
-
// src/actions/package/publint.ts
|
|
69
|
-
import { promises as fs2 } from "fs";
|
|
70
|
-
import chalk4 from "chalk";
|
|
71
|
-
import sortPackageJson from "sort-package-json";
|
|
72
|
-
var packagePublint = async (params) => {
|
|
73
|
-
const pkgDir = process.env.INIT_CWD;
|
|
74
|
-
const sortedPkg = sortPackageJson(await fs2.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
75
|
-
await fs2.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
76
|
-
const pkg = JSON.parse(await fs2.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
77
|
-
console.log(chalk4.green(`Publint: ${pkg.name}`));
|
|
78
|
-
console.log(chalk4.gray(pkgDir));
|
|
79
|
-
const { publint } = await import("publint");
|
|
80
|
-
const { messages } = await publint({
|
|
81
|
-
level: "suggestion",
|
|
82
|
-
pkgDir,
|
|
83
|
-
strict: true
|
|
84
|
-
});
|
|
85
|
-
const { formatMessage } = await import("publint/utils");
|
|
86
|
-
const validMessage = (_message) => {
|
|
87
|
-
return true;
|
|
88
|
-
};
|
|
89
|
-
const validMessages = messages.filter(validMessage);
|
|
90
|
-
for (const message of validMessages) {
|
|
91
|
-
switch (message.type) {
|
|
92
|
-
case "error": {
|
|
93
|
-
console.error(chalk4.red(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
case "warning": {
|
|
97
|
-
console.warn(chalk4.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
default: {
|
|
101
|
-
console.log(chalk4.white(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (params?.verbose) {
|
|
107
|
-
console.log(chalk4.gray(`Publint [Finish]: ${pkgDir} [${validMessages.length}]`));
|
|
108
|
-
}
|
|
109
|
-
return validMessages.filter((message) => message.type === "error").length;
|
|
110
|
-
};
|
|
90
|
+
import chalk8 from "chalk";
|
|
111
91
|
|
|
112
92
|
// src/actions/package/compile/packageCompileTsup.ts
|
|
93
|
+
import chalk7 from "chalk";
|
|
113
94
|
import { build, defineConfig } from "tsup";
|
|
114
95
|
|
|
115
96
|
// src/actions/package/compile/inputs.ts
|
|
97
|
+
import chalk4 from "chalk";
|
|
116
98
|
import { glob as glob2 } from "glob";
|
|
117
|
-
var getAllInputs = (
|
|
118
|
-
return
|
|
119
|
-
}
|
|
99
|
+
var getAllInputs = /* @__PURE__ */ __name((srcDir, verbose = false) => {
|
|
100
|
+
return [
|
|
101
|
+
...glob2.sync(`${srcDir}/**/*.ts`, {
|
|
102
|
+
posix: true
|
|
103
|
+
}).map((file) => {
|
|
104
|
+
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
105
|
+
if (verbose) {
|
|
106
|
+
console.log(chalk4.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
107
|
+
}
|
|
108
|
+
return result;
|
|
109
|
+
}),
|
|
110
|
+
...glob2.sync(`${srcDir}/**/*.tsx`, {
|
|
111
|
+
posix: true
|
|
112
|
+
}).map((file) => {
|
|
113
|
+
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
114
|
+
if (verbose) {
|
|
115
|
+
console.log(chalk4.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
})
|
|
119
|
+
];
|
|
120
|
+
}, "getAllInputs");
|
|
120
121
|
|
|
121
122
|
// src/actions/package/compile/buildEntries.ts
|
|
122
|
-
var buildEntries = (
|
|
123
|
+
var buildEntries = /* @__PURE__ */ __name((srcDir, entryMode = "single", options, excludeSpecAndStories = true, verbose = false) => {
|
|
123
124
|
let entries = [];
|
|
124
125
|
switch (entryMode) {
|
|
125
126
|
case "platform": {
|
|
126
|
-
entries = [
|
|
127
|
+
entries = [
|
|
128
|
+
"index-node.ts",
|
|
129
|
+
"index-browser.ts"
|
|
130
|
+
];
|
|
127
131
|
break;
|
|
128
132
|
}
|
|
129
133
|
case "all": {
|
|
130
|
-
entries = excludeSpecAndStories ? getAllInputs(
|
|
134
|
+
entries = (excludeSpecAndStories ? getAllInputs(srcDir).filter((entry) => !entry.includes(".spec.") && !entry.includes(".stories.")) : getAllInputs(srcDir)).filter((entry) => !entry.endsWith(".d.ts"));
|
|
131
135
|
break;
|
|
132
136
|
}
|
|
133
137
|
case "custom": {
|
|
@@ -135,7 +139,9 @@ var buildEntries = (folder, entryMode = "single", options, excludeSpecAndStories
|
|
|
135
139
|
break;
|
|
136
140
|
}
|
|
137
141
|
default: {
|
|
138
|
-
entries = [
|
|
142
|
+
entries = [
|
|
143
|
+
"index.ts"
|
|
144
|
+
];
|
|
139
145
|
break;
|
|
140
146
|
}
|
|
141
147
|
}
|
|
@@ -144,7 +150,7 @@ var buildEntries = (folder, entryMode = "single", options, excludeSpecAndStories
|
|
|
144
150
|
}
|
|
145
151
|
if (verbose) console.log(`buildEntries [${entryMode}] ${entries.length}`);
|
|
146
152
|
return entries;
|
|
147
|
-
};
|
|
153
|
+
}, "buildEntries");
|
|
148
154
|
|
|
149
155
|
// src/actions/package/compile/deepMerge.ts
|
|
150
156
|
function deepMerge(target, source) {
|
|
@@ -161,6 +167,7 @@ function deepMerge(target, source) {
|
|
|
161
167
|
}
|
|
162
168
|
return target;
|
|
163
169
|
}
|
|
170
|
+
__name(deepMerge, "deepMerge");
|
|
164
171
|
function deepMergeObjects(objects) {
|
|
165
172
|
const result = {};
|
|
166
173
|
for (const obj of objects) {
|
|
@@ -168,180 +175,343 @@ function deepMergeObjects(objects) {
|
|
|
168
175
|
}
|
|
169
176
|
return result;
|
|
170
177
|
}
|
|
178
|
+
__name(deepMergeObjects, "deepMergeObjects");
|
|
171
179
|
|
|
172
|
-
// src/actions/package/compile/
|
|
180
|
+
// src/actions/package/compile/packageCompileTsc.ts
|
|
181
|
+
import { cwd as cwd2 } from "process";
|
|
182
|
+
import chalk5 from "chalk";
|
|
183
|
+
import { createProgramFromConfig } from "tsc-prog";
|
|
184
|
+
import ts, { DiagnosticCategory, formatDiagnosticsWithColorAndContext, getPreEmitDiagnostics, sys } from "typescript";
|
|
185
|
+
|
|
186
|
+
// src/actions/package/compile/getCompilerOptions.ts
|
|
173
187
|
import { cwd } from "process";
|
|
188
|
+
import deepmerge2 from "deepmerge";
|
|
189
|
+
import { getTsconfig } from "get-tsconfig";
|
|
190
|
+
var getCompilerOptions = /* @__PURE__ */ __name((options = {}, fileName = "tsconfig.json") => {
|
|
191
|
+
const resolvedTsConfigCompilerOptions = getTsconfig(cwd(), fileName)?.config?.compilerOptions ?? {};
|
|
192
|
+
return deepmerge2(resolvedTsConfigCompilerOptions, options);
|
|
193
|
+
}, "getCompilerOptions");
|
|
194
|
+
|
|
195
|
+
// src/actions/package/compile/packageCompileTsc.ts
|
|
196
|
+
var packageCompileTsc = /* @__PURE__ */ __name((platform, entries, srcDir = "src", outDir = "dist", compilerOptionsParam, verbose = false) => {
|
|
197
|
+
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
198
|
+
if (verbose) {
|
|
199
|
+
console.log(chalk5.cyan(`Validating code START: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
200
|
+
}
|
|
201
|
+
const configFilePath = ts.findConfigFile("./", ts.sys.fileExists, "tsconfig.json");
|
|
202
|
+
if (configFilePath === void 0) {
|
|
203
|
+
throw new Error("Could not find tsconfig.json");
|
|
204
|
+
}
|
|
205
|
+
const compilerOptions = {
|
|
206
|
+
...getCompilerOptions({
|
|
207
|
+
removeComments: false,
|
|
208
|
+
skipDefaultLibCheck: true,
|
|
209
|
+
skipLibCheck: true,
|
|
210
|
+
sourceMap: false
|
|
211
|
+
}),
|
|
212
|
+
...compilerOptionsParam,
|
|
213
|
+
outDir: `${outDir}/${platform}`,
|
|
214
|
+
emitDeclarationOnly: true,
|
|
215
|
+
noEmit: false
|
|
216
|
+
};
|
|
217
|
+
console.log(chalk5.cyan(`Validating Files: ${entries.length}`));
|
|
218
|
+
if (verbose) {
|
|
219
|
+
for (const entry of entries) {
|
|
220
|
+
console.log(chalk5.grey(`Validating: ${entry}`));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
try {
|
|
224
|
+
if (entries.length > 0) {
|
|
225
|
+
const program = createProgramFromConfig({
|
|
226
|
+
configFilePath,
|
|
227
|
+
basePath: pkg ?? cwd2(),
|
|
228
|
+
compilerOptions,
|
|
229
|
+
files: entries.map((entry) => `${srcDir}/${entry}`),
|
|
230
|
+
include: [
|
|
231
|
+
`${srcDir}/**/*.*`
|
|
232
|
+
]
|
|
233
|
+
});
|
|
234
|
+
const diagnostics = getPreEmitDiagnostics(program);
|
|
235
|
+
if (diagnostics.length > 0) {
|
|
236
|
+
const formattedDiagnostics = formatDiagnosticsWithColorAndContext(diagnostics, {
|
|
237
|
+
getCanonicalFileName: /* @__PURE__ */ __name((fileName) => fileName, "getCanonicalFileName"),
|
|
238
|
+
getCurrentDirectory: /* @__PURE__ */ __name(() => srcDir, "getCurrentDirectory"),
|
|
239
|
+
getNewLine: /* @__PURE__ */ __name(() => sys.newLine, "getNewLine")
|
|
240
|
+
});
|
|
241
|
+
console.error(formattedDiagnostics);
|
|
242
|
+
}
|
|
243
|
+
program.emit();
|
|
244
|
+
return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0);
|
|
245
|
+
}
|
|
246
|
+
return 0;
|
|
247
|
+
} finally {
|
|
248
|
+
if (verbose) {
|
|
249
|
+
console.log(chalk5.cyan(`Validating code FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}, "packageCompileTsc");
|
|
253
|
+
|
|
254
|
+
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
255
|
+
import path3 from "path";
|
|
256
|
+
import { cwd as cwd3 } from "process";
|
|
257
|
+
import chalk6 from "chalk";
|
|
174
258
|
import { rollup } from "rollup";
|
|
175
259
|
import dts from "rollup-plugin-dts";
|
|
176
260
|
import nodeExternals from "rollup-plugin-node-externals";
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
261
|
+
var ignoredWarningCodes = /* @__PURE__ */ new Set([
|
|
262
|
+
"EMPTY_BUNDLE",
|
|
263
|
+
"UNRESOLVED_IMPORT"
|
|
264
|
+
]);
|
|
265
|
+
async function bundleDts(inputPath, outputPath, platform, options, verbose = false) {
|
|
266
|
+
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
267
|
+
const tsconfigPath = path3.resolve(pkg, "tsconfig.json");
|
|
268
|
+
const nodePlugIns = platform === "node" ? [
|
|
269
|
+
nodeExternals()
|
|
270
|
+
] : [];
|
|
271
|
+
try {
|
|
272
|
+
const bundle = await rollup({
|
|
273
|
+
input: inputPath,
|
|
274
|
+
plugins: [
|
|
275
|
+
dts({
|
|
276
|
+
...options,
|
|
277
|
+
tsconfig: tsconfigPath,
|
|
278
|
+
compilerOptions: {
|
|
279
|
+
emitDeclarationOnly: true,
|
|
280
|
+
noEmit: false,
|
|
281
|
+
declarationMap: true
|
|
282
|
+
}
|
|
283
|
+
}),
|
|
284
|
+
...nodePlugIns
|
|
285
|
+
],
|
|
286
|
+
onwarn(warning, warn) {
|
|
287
|
+
if (ignoredWarningCodes.has(warning.code ?? "")) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
console.warn(chalk6.yellow(`[${warning.code}] ${warning.message}`));
|
|
291
|
+
console.warn(chalk6.gray(inputPath));
|
|
292
|
+
warn(warning);
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
await bundle.write({
|
|
296
|
+
file: outputPath,
|
|
297
|
+
format: "es"
|
|
298
|
+
});
|
|
299
|
+
} catch (ex) {
|
|
300
|
+
const error = ex;
|
|
301
|
+
console.warn(chalk6.red(error));
|
|
302
|
+
console.warn(chalk6.gray(inputPath));
|
|
303
|
+
}
|
|
304
|
+
if (verbose) {
|
|
305
|
+
console.log(`Bundled declarations written to ${outputPath}`);
|
|
306
|
+
}
|
|
192
307
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
308
|
+
__name(bundleDts, "bundleDts");
|
|
309
|
+
var packageCompileTscTypes = /* @__PURE__ */ __name(async (entries, outDir, platform, srcDir = "build", verbose = false) => {
|
|
310
|
+
if (verbose) {
|
|
311
|
+
console.log(chalk6.cyan(`Compiling Types START [${platform}]: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
312
|
+
console.log(`Entries: ${entries.join(", ")}`);
|
|
313
|
+
}
|
|
314
|
+
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
315
|
+
const srcRoot = `${pkg}/${srcDir}/${platform}`;
|
|
316
|
+
const entryNameToTypeName = /* @__PURE__ */ __name((entry) => {
|
|
197
317
|
const splitEntryName = entry.split(".");
|
|
198
318
|
const newEntryExtension = "d." + splitEntryName.at(-1);
|
|
199
|
-
return [
|
|
200
|
-
|
|
201
|
-
|
|
319
|
+
return [
|
|
320
|
+
...splitEntryName.slice(0, -1),
|
|
321
|
+
newEntryExtension
|
|
322
|
+
].join(".");
|
|
323
|
+
}, "entryNameToTypeName");
|
|
324
|
+
const compilerOptions = getCompilerOptions({
|
|
325
|
+
removeComments: false,
|
|
326
|
+
skipDefaultLibCheck: true,
|
|
327
|
+
skipLibCheck: true,
|
|
328
|
+
declarationMap: true,
|
|
329
|
+
emitDeclarationOnly: true,
|
|
330
|
+
noEmit: true
|
|
331
|
+
});
|
|
332
|
+
const entryNames = entries.map((entry) => entry.split(`${srcDir}/`).at(-1) ?? entry);
|
|
202
333
|
await Promise.all(entryNames.map(async (entryName) => {
|
|
203
|
-
|
|
334
|
+
const entryTypeName = entryNameToTypeName(entryName);
|
|
335
|
+
await bundleDts(`${srcRoot}/${entryTypeName}`, `${outDir}/${entryTypeName}`, platform, {
|
|
336
|
+
compilerOptions
|
|
337
|
+
}, verbose);
|
|
204
338
|
}));
|
|
339
|
+
if (verbose) {
|
|
340
|
+
console.log(chalk6.cyan(`Compiling Types FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
341
|
+
}
|
|
205
342
|
return 0;
|
|
206
|
-
};
|
|
343
|
+
}, "packageCompileTscTypes");
|
|
207
344
|
|
|
208
345
|
// src/actions/package/compile/packageCompileTsup.ts
|
|
209
|
-
var compileFolder = async (
|
|
346
|
+
var compileFolder = /* @__PURE__ */ __name(async (srcDir, entries, buildDir, options, bundleTypes = false, verbose) => {
|
|
210
347
|
const outDir = options?.outDir ?? "dist";
|
|
211
348
|
if (verbose) {
|
|
212
|
-
console.log(`compileFolder [${
|
|
349
|
+
console.log(`compileFolder [${srcDir}, ${options?.outDir}]`);
|
|
213
350
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
351
|
+
if (entries.length === 0) {
|
|
352
|
+
console.warn(chalk7.yellow(`No entries found in ${srcDir} to compile`));
|
|
353
|
+
return 0;
|
|
354
|
+
}
|
|
355
|
+
if (verbose) {
|
|
356
|
+
console.log(chalk7.gray(`buildDir [${buildDir}]`));
|
|
357
|
+
}
|
|
358
|
+
const validationResult = packageCompileTsc(options?.platform ?? "neutral", entries, srcDir, buildDir, void 0, verbose);
|
|
359
|
+
if (validationResult !== 0) {
|
|
360
|
+
console.error(chalk7.red(`Compile:Validation had ${validationResult} errors`));
|
|
361
|
+
return validationResult;
|
|
362
|
+
}
|
|
363
|
+
const optionsParams = tsupOptions([
|
|
364
|
+
{
|
|
365
|
+
bundle: true,
|
|
366
|
+
cjsInterop: true,
|
|
367
|
+
clean: false,
|
|
368
|
+
dts: false,
|
|
369
|
+
format: [
|
|
370
|
+
"esm"
|
|
371
|
+
],
|
|
372
|
+
outDir,
|
|
373
|
+
silent: true,
|
|
374
|
+
sourcemap: true,
|
|
375
|
+
splitting: false,
|
|
376
|
+
tsconfig: "tsconfig.json",
|
|
377
|
+
...options,
|
|
378
|
+
entry: entries.map((entry) => `${srcDir}/${entry}`)
|
|
379
|
+
}
|
|
380
|
+
]);
|
|
381
|
+
const optionsResult = defineConfig(optionsParams);
|
|
382
|
+
const optionsList = (await Promise.all((Array.isArray(optionsResult) ? optionsResult : [
|
|
383
|
+
optionsResult
|
|
384
|
+
]).flatMap(async (options2) => {
|
|
385
|
+
const result = typeof options2 === "function" ? await options2({}) : [
|
|
386
|
+
options2
|
|
387
|
+
];
|
|
388
|
+
return Array.isArray(result) ? result : [
|
|
389
|
+
result
|
|
390
|
+
];
|
|
391
|
+
}))).flat();
|
|
234
392
|
if (verbose) {
|
|
235
|
-
console.log(`TSUP:build:start [${
|
|
393
|
+
console.log(chalk7.cyan(`TSUP:build:start [${srcDir}]`));
|
|
394
|
+
console.log(chalk7.gray(`TSUP:build:options [${JSON.stringify(optionsList, null, 2)}]`));
|
|
236
395
|
}
|
|
237
396
|
await Promise.all(optionsList.map((options2) => build(options2)));
|
|
238
397
|
if (verbose) {
|
|
239
|
-
console.log(`TSUP:build:stop [${
|
|
398
|
+
console.log(chalk7.cyan(`TSUP:build:stop [${srcDir}]`));
|
|
399
|
+
}
|
|
400
|
+
if (bundleTypes) {
|
|
401
|
+
await packageCompileTscTypes(entries, outDir, options?.platform ?? "neutral", buildDir, verbose);
|
|
240
402
|
}
|
|
241
|
-
await packageCompileTscTypes(entries, outDir, options?.platform ?? "neutral", folder);
|
|
242
403
|
return 0;
|
|
243
|
-
};
|
|
244
|
-
var tsupOptions = (options = []) => {
|
|
404
|
+
}, "compileFolder");
|
|
405
|
+
var tsupOptions = /* @__PURE__ */ __name((options = []) => {
|
|
245
406
|
const standardLoaders = {
|
|
246
407
|
".gif": "copy",
|
|
247
408
|
".html": "copy",
|
|
248
409
|
".jpg": "copy",
|
|
249
410
|
".json": "json",
|
|
250
411
|
".png": "copy",
|
|
251
|
-
".svg": "
|
|
412
|
+
".svg": "text",
|
|
252
413
|
".webp": "copy"
|
|
253
414
|
};
|
|
254
415
|
const standardOptions = {
|
|
255
416
|
bundle: true,
|
|
256
|
-
format: [
|
|
417
|
+
format: [
|
|
418
|
+
"esm"
|
|
419
|
+
],
|
|
257
420
|
loader: standardLoaders,
|
|
258
|
-
outExtension: ({ format }) => format === "esm" ? {
|
|
421
|
+
outExtension: /* @__PURE__ */ __name(({ format }) => format === "esm" ? {
|
|
422
|
+
js: ".mjs"
|
|
423
|
+
} : {
|
|
424
|
+
js: ".cjs"
|
|
425
|
+
}, "outExtension"),
|
|
259
426
|
skipNodeModulesBundle: true,
|
|
260
427
|
sourcemap: true,
|
|
261
428
|
target: "esnext"
|
|
262
429
|
};
|
|
263
|
-
return deepMergeObjects([
|
|
264
|
-
|
|
265
|
-
|
|
430
|
+
return deepMergeObjects([
|
|
431
|
+
standardOptions,
|
|
432
|
+
...options
|
|
433
|
+
]);
|
|
434
|
+
}, "tsupOptions");
|
|
435
|
+
var packageCompileTsup = /* @__PURE__ */ __name(async (config2) => {
|
|
266
436
|
const compile = config2?.compile;
|
|
267
437
|
const verbose = config2?.verbose ?? false;
|
|
438
|
+
const outDirAsBuildDir = compile?.outDirAsBuildDir ?? true;
|
|
439
|
+
const bundleTypes = compile?.bundleTypes ?? false;
|
|
268
440
|
if (verbose) {
|
|
269
|
-
console.log(
|
|
270
|
-
}
|
|
271
|
-
const compileForNode = compile?.node ?? { src: {} };
|
|
272
|
-
const compileForBrowser = compile?.browser ?? { src: {} };
|
|
273
|
-
const compileForNeutral = compile?.neutral ?? { src: {} };
|
|
274
|
-
if (verbose) {
|
|
275
|
-
console.log("Calling packageCompileTscTypes");
|
|
441
|
+
console.log("Compiling with TSUP");
|
|
276
442
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
443
|
+
const compileForNode = compile?.node ?? {
|
|
444
|
+
src: {}
|
|
445
|
+
};
|
|
446
|
+
const compileForBrowser = compile?.browser ?? {
|
|
447
|
+
src: {}
|
|
448
|
+
};
|
|
449
|
+
const compileForNeutral = compile?.neutral ?? {
|
|
450
|
+
src: {}
|
|
451
|
+
};
|
|
452
|
+
return (await Promise.all(Object.entries(compileForNode).map(async ([srcDir, options]) => {
|
|
453
|
+
const optionsObject = typeof options === "object" ? options : {};
|
|
454
|
+
const inEsBuildOptions = typeof compile?.node?.esbuildOptions === "object" ? compile?.node?.esbuildOptions : {};
|
|
455
|
+
const entry = buildEntries(srcDir, compile?.entryMode, options, true, verbose);
|
|
456
|
+
const platform = "node";
|
|
457
|
+
const rootOutDir = optionsObject.outDir ?? "dist";
|
|
458
|
+
const outDir = rootOutDir + "/" + platform;
|
|
459
|
+
return typeof srcDir === "string" ? await compileFolder(srcDir, entry, outDirAsBuildDir ? rootOutDir : "build", tsupOptions([
|
|
460
|
+
inEsBuildOptions,
|
|
461
|
+
compile?.tsup?.options ?? {},
|
|
462
|
+
typeof options === "object" ? options : {},
|
|
463
|
+
{
|
|
464
|
+
platform: "node",
|
|
465
|
+
outDir
|
|
466
|
+
}
|
|
467
|
+
]), bundleTypes, verbose) : 0;
|
|
468
|
+
}))).reduce((prev, value) => prev + value, 0) + (await Promise.all(Object.entries(compileForBrowser).map(async ([srcDir, options]) => {
|
|
469
|
+
const optionsObject = typeof options === "object" ? options : {};
|
|
470
|
+
const inEsBuildOptions = typeof compile?.browser?.esbuildOptions === "object" ? compile?.browser?.esbuildOptions : {};
|
|
471
|
+
const entry = buildEntries(srcDir, compile?.entryMode, options, true, verbose);
|
|
472
|
+
const platform = "browser";
|
|
473
|
+
const rootOutDir = optionsObject.outDir ?? "dist";
|
|
474
|
+
const outDir = rootOutDir + "/" + platform;
|
|
475
|
+
return typeof srcDir === "string" ? await compileFolder(srcDir, entry, outDirAsBuildDir ? rootOutDir : "build", tsupOptions([
|
|
476
|
+
inEsBuildOptions,
|
|
477
|
+
compile?.tsup?.options ?? {},
|
|
478
|
+
typeof options === "object" ? options : {},
|
|
479
|
+
{
|
|
480
|
+
platform: "browser",
|
|
481
|
+
outDir
|
|
482
|
+
}
|
|
483
|
+
]), bundleTypes, verbose) : 0;
|
|
484
|
+
}))).reduce((prev, value) => prev + value, 0) + (await Promise.all(Object.entries(compileForNeutral).map(async ([srcDir, options]) => {
|
|
485
|
+
const optionsObject = typeof options === "object" ? options : {};
|
|
486
|
+
const inEsBuildOptions = typeof compile?.neutral?.esbuildOptions === "object" ? compile?.neutral?.esbuildOptions : {};
|
|
487
|
+
const entry = buildEntries(srcDir, compile?.entryMode, options, true, verbose);
|
|
488
|
+
const platform = "neutral";
|
|
489
|
+
const rootOutDir = optionsObject.outDir ?? "dist";
|
|
490
|
+
const outDir = rootOutDir + "/" + platform;
|
|
491
|
+
return typeof srcDir === "string" ? await compileFolder(srcDir, entry, outDirAsBuildDir ? rootOutDir : "build", tsupOptions([
|
|
492
|
+
inEsBuildOptions,
|
|
493
|
+
compile?.tsup?.options ?? {},
|
|
494
|
+
typeof options === "object" ? options : {},
|
|
495
|
+
{
|
|
496
|
+
platform: "neutral",
|
|
497
|
+
outDir
|
|
498
|
+
}
|
|
499
|
+
]), bundleTypes, verbose) : 0;
|
|
500
|
+
}))).reduce((prev, value) => prev + value, 0) + 0;
|
|
501
|
+
}, "packageCompileTsup");
|
|
327
502
|
|
|
328
503
|
// src/actions/package/compile/compile.ts
|
|
329
|
-
var packageCompile = async (inConfig = {}) => {
|
|
504
|
+
var packageCompile = /* @__PURE__ */ __name(async (inConfig = {}) => {
|
|
330
505
|
const pkg = process.env.INIT_CWD;
|
|
331
|
-
console.log(
|
|
506
|
+
console.log(chalk8.green(`Compiling ${pkg}`));
|
|
332
507
|
const config2 = await loadConfig(inConfig);
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
if (tsupResults > 0) {
|
|
336
|
-
return tsupResults;
|
|
337
|
-
}
|
|
338
|
-
return publint ? await packagePublint(config2) : 0;
|
|
339
|
-
};
|
|
508
|
+
return await packageCompileTsup(config2);
|
|
509
|
+
}, "packageCompile");
|
|
340
510
|
|
|
341
511
|
// src/actions/package/recompile.ts
|
|
342
|
-
var packageRecompile = async () => {
|
|
512
|
+
var packageRecompile = /* @__PURE__ */ __name(async () => {
|
|
343
513
|
return await packageClean() || await packageCompile();
|
|
344
|
-
};
|
|
514
|
+
}, "packageRecompile");
|
|
345
515
|
export {
|
|
346
516
|
packageRecompile
|
|
347
517
|
};
|