@xylabs/ts-scripts-yarn3 7.0.2 → 7.1.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/actions/build.mjs +39 -87
- package/dist/actions/build.mjs.map +1 -1
- package/dist/actions/clean-docs.mjs +8 -22
- package/dist/actions/clean-docs.mjs.map +1 -1
- package/dist/actions/clean-eslint.mjs +5 -11
- package/dist/actions/clean-eslint.mjs.map +1 -1
- package/dist/actions/clean-jest.mjs +16 -29
- package/dist/actions/clean-jest.mjs.map +1 -1
- package/dist/actions/clean.mjs +32 -63
- package/dist/actions/clean.mjs.map +1 -1
- package/dist/actions/compile.mjs +50 -76
- package/dist/actions/compile.mjs.map +1 -1
- package/dist/actions/copy-assets.mjs +23 -38
- package/dist/actions/copy-assets.mjs.map +1 -1
- package/dist/actions/cycle.mjs +28 -57
- package/dist/actions/cycle.mjs.map +1 -1
- package/dist/actions/dead.mjs +16 -31
- package/dist/actions/dead.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/checkPackage.mjs +48 -71
- package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs +5 -5
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +9 -5
- 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 +0 -4
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/index.mjs +48 -71
- package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
- package/dist/actions/deplint/deplint.mjs +61 -86
- package/dist/actions/deplint/deplint.mjs.map +1 -1
- package/dist/actions/deplint/findFiles.mjs +4 -20
- package/dist/actions/deplint/findFiles.mjs.map +1 -1
- package/dist/actions/deplint/findFilesByGlob.mjs +1 -8
- package/dist/actions/deplint/findFilesByGlob.mjs.map +1 -1
- package/dist/actions/deplint/getBasePackageName.mjs +0 -4
- package/dist/actions/deplint/getBasePackageName.mjs.map +1 -1
- package/dist/actions/deplint/getDependenciesFromPackageJson.mjs +0 -4
- package/dist/actions/deplint/getDependenciesFromPackageJson.mjs.map +1 -1
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs +12 -24
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs.map +1 -1
- package/dist/actions/deplint/getImportsFromFile.mjs +9 -16
- package/dist/actions/deplint/getImportsFromFile.mjs.map +1 -1
- package/dist/actions/deplint/index.mjs +61 -86
- package/dist/actions/deplint/index.mjs.map +1 -1
- package/dist/actions/deploy-major.mjs +26 -57
- package/dist/actions/deploy-major.mjs.map +1 -1
- package/dist/actions/deploy-minor.mjs +26 -57
- package/dist/actions/deploy-minor.mjs.map +1 -1
- package/dist/actions/deploy-next.mjs +26 -57
- package/dist/actions/deploy-next.mjs.map +1 -1
- package/dist/actions/deploy.mjs +26 -57
- package/dist/actions/deploy.mjs.map +1 -1
- package/dist/actions/dupdeps.mjs +26 -37
- package/dist/actions/dupdeps.mjs.map +1 -1
- package/dist/actions/fix.mjs +36 -54
- package/dist/actions/fix.mjs.map +1 -1
- package/dist/actions/gen-docs.mjs +25 -65
- package/dist/actions/gen-docs.mjs.map +1 -1
- package/dist/actions/gitignore-gen.mjs +28 -44
- package/dist/actions/gitignore-gen.mjs.map +1 -1
- package/dist/actions/gitlint-fix.mjs +5 -14
- package/dist/actions/gitlint-fix.mjs.map +1 -1
- package/dist/actions/gitlint.mjs +4 -7
- package/dist/actions/gitlint.mjs.map +1 -1
- package/dist/actions/index.mjs +705 -1251
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/knip.mjs +16 -31
- package/dist/actions/knip.mjs.map +1 -1
- package/dist/actions/license.mjs +37 -51
- package/dist/actions/license.mjs.map +1 -1
- package/dist/actions/lint.mjs +33 -48
- package/dist/actions/lint.mjs.map +1 -1
- package/dist/actions/npmignore-gen.mjs +28 -44
- package/dist/actions/npmignore-gen.mjs.map +1 -1
- package/dist/actions/package/clean-outputs.mjs +6 -16
- package/dist/actions/package/clean-outputs.mjs.map +1 -1
- package/dist/actions/package/clean-typescript.mjs +6 -16
- package/dist/actions/package/clean-typescript.mjs.map +1 -1
- package/dist/actions/package/clean.mjs +12 -29
- package/dist/actions/package/clean.mjs.map +1 -1
- package/dist/actions/package/compile/buildEntries.mjs +19 -34
- package/dist/actions/package/compile/buildEntries.mjs.map +1 -1
- package/dist/actions/package/compile/compile.mjs +165 -195
- package/dist/actions/package/compile/compile.mjs.map +1 -1
- package/dist/actions/package/compile/copyTypeFiles.mjs +20 -23
- package/dist/actions/package/compile/copyTypeFiles.mjs.map +1 -1
- package/dist/actions/package/compile/deepMerge.mjs +0 -5
- package/dist/actions/package/compile/deepMerge.mjs.map +1 -1
- package/dist/actions/package/compile/getCompilerOptions.mjs +2 -5
- package/dist/actions/package/compile/getCompilerOptions.mjs.map +1 -1
- package/dist/actions/package/compile/index.mjs +165 -195
- package/dist/actions/package/compile/index.mjs.map +1 -1
- package/dist/actions/package/compile/inputs.mjs +15 -25
- package/dist/actions/package/compile/inputs.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTsc.mjs +25 -17
- package/dist/actions/package/compile/packageCompileTsc.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTscTypes.mjs +19 -36
- package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTsup.mjs +160 -185
- package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -1
- package/dist/actions/package/copy-assets.mjs +12 -21
- package/dist/actions/package/copy-assets.mjs.map +1 -1
- package/dist/actions/package/cycle.mjs +5 -14
- package/dist/actions/package/cycle.mjs.map +1 -1
- package/dist/actions/package/gen-docs.mjs +11 -12
- package/dist/actions/package/gen-docs.mjs.map +1 -1
- package/dist/actions/package/index.mjs +236 -308
- package/dist/actions/package/index.mjs.map +1 -1
- package/dist/actions/package/lint.mjs +16 -39
- package/dist/actions/package/lint.mjs.map +1 -1
- package/dist/actions/package/publint.mjs +13 -14
- package/dist/actions/package/publint.mjs.map +1 -1
- package/dist/actions/package/recompile.mjs +179 -223
- package/dist/actions/package/recompile.mjs.map +1 -1
- package/dist/actions/publint.mjs +37 -71
- package/dist/actions/publint.mjs.map +1 -1
- package/dist/actions/rebuild.mjs +17 -29
- package/dist/actions/rebuild.mjs.map +1 -1
- package/dist/actions/recompile.mjs +50 -67
- package/dist/actions/recompile.mjs.map +1 -1
- package/dist/actions/reinstall.mjs +25 -43
- package/dist/actions/reinstall.mjs.map +1 -1
- package/dist/actions/relint.mjs +40 -63
- package/dist/actions/relint.mjs.map +1 -1
- package/dist/actions/retest.mjs +17 -35
- package/dist/actions/retest.mjs.map +1 -1
- package/dist/actions/sonar.mjs +16 -32
- package/dist/actions/sonar.mjs.map +1 -1
- package/dist/actions/statics.mjs +27 -46
- package/dist/actions/statics.mjs.map +1 -1
- package/dist/actions/test.mjs +16 -30
- package/dist/actions/test.mjs.map +1 -1
- package/dist/actions/up.mjs +16 -27
- package/dist/actions/up.mjs.map +1 -1
- package/dist/actions/updo.mjs +18 -33
- package/dist/actions/updo.mjs.map +1 -1
- package/dist/actions/upplug.mjs +19 -53
- package/dist/actions/upplug.mjs.map +1 -1
- package/dist/actions/upyarn.mjs +16 -31
- package/dist/actions/upyarn.mjs.map +1 -1
- package/dist/actions/yarn3only.mjs +12 -23
- package/dist/actions/yarn3only.mjs.map +1 -1
- package/dist/bin/package/build-only.mjs +165 -194
- package/dist/bin/package/build-only.mjs.map +1 -1
- package/dist/bin/package/build.mjs +166 -197
- package/dist/bin/package/build.mjs.map +1 -1
- package/dist/bin/package/clean-outputs.mjs +6 -15
- package/dist/bin/package/clean-outputs.mjs.map +1 -1
- package/dist/bin/package/clean-typescript.mjs +6 -15
- package/dist/bin/package/clean-typescript.mjs.map +1 -1
- package/dist/bin/package/clean.mjs +12 -28
- package/dist/bin/package/clean.mjs.map +1 -1
- package/dist/bin/package/compile-only.mjs +165 -194
- package/dist/bin/package/compile-only.mjs.map +1 -1
- package/dist/bin/package/compile-tsup.mjs +160 -184
- package/dist/bin/package/compile-tsup.mjs.map +1 -1
- package/dist/bin/package/compile.mjs +165 -194
- package/dist/bin/package/compile.mjs.map +1 -1
- package/dist/bin/package/copy-assets-cjs.mjs +13 -23
- package/dist/bin/package/copy-assets-cjs.mjs.map +1 -1
- package/dist/bin/package/copy-assets-esm.mjs +13 -23
- package/dist/bin/package/copy-assets-esm.mjs.map +1 -1
- package/dist/bin/package/cycle.mjs +5 -13
- package/dist/bin/package/cycle.mjs.map +1 -1
- package/dist/bin/package/fix.mjs +16 -38
- package/dist/bin/package/fix.mjs.map +1 -1
- package/dist/bin/package/gen-docs.mjs +11 -11
- package/dist/bin/package/gen-docs.mjs.map +1 -1
- package/dist/bin/package/lint.mjs +16 -38
- package/dist/bin/package/lint.mjs.map +1 -1
- package/dist/bin/package/publint.mjs +13 -13
- package/dist/bin/package/publint.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +179 -222
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/bin/package/relint.mjs +16 -38
- package/dist/bin/package/relint.mjs.map +1 -1
- package/dist/bin/xy.mjs +932 -1266
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.mjs +1191 -1612
- package/dist/index.mjs.map +1 -1
- package/dist/lib/checkResult.mjs +2 -5
- package/dist/lib/checkResult.mjs.map +1 -1
- package/dist/lib/createBuildConfig.mjs +9 -24
- package/dist/lib/createBuildConfig.mjs.map +1 -1
- package/dist/lib/defaultBuildConfig.mjs +2 -6
- package/dist/lib/defaultBuildConfig.mjs.map +1 -1
- package/dist/lib/deleteGlob.mjs +3 -9
- package/dist/lib/deleteGlob.mjs.map +1 -1
- package/dist/lib/dependencies/DuplicateDetector.mjs +12 -23
- package/dist/lib/dependencies/DuplicateDetector.mjs.map +1 -1
- package/dist/lib/dependencies/detectDuplicateDependencies.mjs +22 -33
- package/dist/lib/dependencies/detectDuplicateDependencies.mjs.map +1 -1
- package/dist/lib/dependencies/index.mjs +22 -33
- package/dist/lib/dependencies/index.mjs.map +1 -1
- package/dist/lib/file/ReadFileSyncOptions.mjs +1 -3
- package/dist/lib/file/ReadFileSyncOptions.mjs.map +1 -1
- package/dist/lib/file/constants.mjs.map +1 -1
- package/dist/lib/file/fileLines.mjs +12 -13
- package/dist/lib/file/fileLines.mjs.map +1 -1
- package/dist/lib/file/index.mjs +14 -15
- package/dist/lib/file/index.mjs.map +1 -1
- package/dist/lib/file/tryReadFileSync.mjs +3 -8
- package/dist/lib/file/tryReadFileSync.mjs.map +1 -1
- package/dist/lib/generateIgnoreFiles.mjs +27 -43
- package/dist/lib/generateIgnoreFiles.mjs.map +1 -1
- package/dist/lib/index.mjs +99 -157
- package/dist/lib/index.mjs.map +1 -1
- package/dist/lib/jsonFormatters.mjs +2 -5
- package/dist/lib/jsonFormatters.mjs.map +1 -1
- package/dist/lib/loadConfig.mjs +3 -11
- package/dist/lib/loadConfig.mjs.map +1 -1
- package/dist/lib/parsedPackageJSON.mjs +2 -5
- package/dist/lib/parsedPackageJSON.mjs.map +1 -1
- package/dist/lib/processEx.mjs +6 -9
- package/dist/lib/processEx.mjs.map +1 -1
- package/dist/lib/runSteps.mjs +13 -19
- 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 +19 -31
- package/dist/lib/runXy.mjs.map +1 -1
- package/dist/lib/runXyWithWarning.mjs +2 -5
- package/dist/lib/runXyWithWarning.mjs.map +1 -1
- package/dist/lib/safeExit.mjs +10 -13
- package/dist/lib/safeExit.mjs.map +1 -1
- package/dist/lib/string/empty.mjs +2 -5
- package/dist/lib/string/empty.mjs.map +1 -1
- package/dist/lib/string/index.mjs +3 -9
- package/dist/lib/string/index.mjs.map +1 -1
- package/dist/lib/string/union.mjs +1 -7
- package/dist/lib/string/union.mjs.map +1 -1
- package/dist/lib/withErrnoException.mjs +4 -7
- package/dist/lib/withErrnoException.mjs.map +1 -1
- package/dist/lib/withError.mjs +2 -5
- package/dist/lib/withError.mjs.map +1 -1
- package/dist/lib/yarn/index.mjs +11 -30
- package/dist/lib/yarn/index.mjs.map +1 -1
- package/dist/lib/yarn/isYarnVersionOrGreater.mjs +4 -15
- package/dist/lib/yarn/isYarnVersionOrGreater.mjs.map +1 -1
- package/dist/lib/yarn/workspace/index.mjs +5 -16
- package/dist/lib/yarn/workspace/index.mjs.map +1 -1
- package/dist/lib/yarn/workspace/yarnWorkspace.mjs +5 -16
- package/dist/lib/yarn/workspace/yarnWorkspace.mjs.map +1 -1
- package/dist/lib/yarn/workspace/yarnWorkspaces.mjs +3 -14
- package/dist/lib/yarn/workspace/yarnWorkspaces.mjs.map +1 -1
- package/dist/lib/yarn/yarnInitCwd.mjs +2 -5
- package/dist/lib/yarn/yarnInitCwd.mjs.map +1 -1
- package/dist/loadPackageConfig.mjs +3 -8
- package/dist/loadPackageConfig.mjs.map +1 -1
- package/dist/xy/index.mjs +932 -1267
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/param.mjs +3 -9
- package/dist/xy/param.mjs.map +1 -1
- package/dist/xy/xy.mjs +932 -1267
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyBuildCommands.mjs +228 -320
- package/dist/xy/xyBuildCommands.mjs.map +1 -1
- package/dist/xy/xyCommonCommands.mjs +251 -336
- package/dist/xy/xyCommonCommands.mjs.map +1 -1
- package/dist/xy/xyDeployCommands.mjs +99 -161
- package/dist/xy/xyDeployCommands.mjs.map +1 -1
- package/dist/xy/xyInstallCommands.mjs +145 -193
- package/dist/xy/xyInstallCommands.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +302 -403
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/dist/xy/xyParseOptions.mjs +2 -5
- package/dist/xy/xyParseOptions.mjs.map +1 -1
- package/package.json +8 -9
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/actions/package/clean-outputs.ts
|
|
5
2
|
import path from "path";
|
|
6
3
|
import chalk2 from "chalk";
|
|
@@ -8,15 +5,12 @@ import chalk2 from "chalk";
|
|
|
8
5
|
// src/lib/deleteGlob.ts
|
|
9
6
|
import fs from "fs";
|
|
10
7
|
import { glob } from "glob";
|
|
11
|
-
var deleteGlob =
|
|
8
|
+
var deleteGlob = (globPath) => {
|
|
12
9
|
const files = glob.sync(globPath);
|
|
13
10
|
for (const file of files) {
|
|
14
|
-
fs.rmSync(file, {
|
|
15
|
-
recursive: true,
|
|
16
|
-
force: true
|
|
17
|
-
});
|
|
11
|
+
fs.rmSync(file, { recursive: true, force: true });
|
|
18
12
|
}
|
|
19
|
-
}
|
|
13
|
+
};
|
|
20
14
|
|
|
21
15
|
// src/lib/loadConfig.ts
|
|
22
16
|
import chalk from "chalk";
|
|
@@ -24,14 +18,9 @@ import { cosmiconfig } from "cosmiconfig";
|
|
|
24
18
|
import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
|
|
25
19
|
import deepmerge from "deepmerge";
|
|
26
20
|
var config;
|
|
27
|
-
var loadConfig =
|
|
21
|
+
var loadConfig = async (params) => {
|
|
28
22
|
if (config === void 0) {
|
|
29
|
-
const cosmicConfigResult = await cosmiconfig("xy", {
|
|
30
|
-
cache: true,
|
|
31
|
-
loaders: {
|
|
32
|
-
".ts": TypeScriptLoader()
|
|
33
|
-
}
|
|
34
|
-
}).search();
|
|
23
|
+
const cosmicConfigResult = await cosmiconfig("xy", { cache: true, loaders: { ".ts": TypeScriptLoader() } }).search();
|
|
35
24
|
config = cosmicConfigResult?.config;
|
|
36
25
|
const configFilePath = cosmicConfigResult?.filepath;
|
|
37
26
|
if (configFilePath !== void 0) {
|
|
@@ -42,49 +31,38 @@ var loadConfig = /* @__PURE__ */ __name(async (params) => {
|
|
|
42
31
|
}
|
|
43
32
|
}
|
|
44
33
|
return deepmerge(config, params ?? {});
|
|
45
|
-
}
|
|
34
|
+
};
|
|
46
35
|
|
|
47
36
|
// src/actions/package/clean-outputs.ts
|
|
48
|
-
var packageCleanOutputs =
|
|
37
|
+
var packageCleanOutputs = () => {
|
|
49
38
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
50
39
|
const pkgName = process.env.npm_package_name;
|
|
51
|
-
const folders = [
|
|
52
|
-
path.join(pkg, "dist"),
|
|
53
|
-
path.join(pkg, "build"),
|
|
54
|
-
path.join(pkg, "docs")
|
|
55
|
-
];
|
|
40
|
+
const folders = [path.join(pkg, "dist"), path.join(pkg, "build"), path.join(pkg, "docs")];
|
|
56
41
|
console.log(chalk2.green(`Cleaning Outputs [${pkgName}]`));
|
|
57
42
|
for (let folder of folders) {
|
|
58
43
|
deleteGlob(folder);
|
|
59
44
|
}
|
|
60
45
|
return 0;
|
|
61
|
-
}
|
|
46
|
+
};
|
|
62
47
|
|
|
63
48
|
// src/actions/package/clean-typescript.ts
|
|
64
49
|
import path2 from "path";
|
|
65
50
|
import chalk3 from "chalk";
|
|
66
|
-
var packageCleanTypescript =
|
|
51
|
+
var packageCleanTypescript = () => {
|
|
67
52
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
68
53
|
const pkgName = process.env.npm_package_name;
|
|
69
54
|
console.log(chalk3.green(`Cleaning Typescript [${pkgName}]`));
|
|
70
|
-
const files = [
|
|
71
|
-
path2.join(pkg, "*.tsbuildinfo"),
|
|
72
|
-
path2.join(pkg, ".tsconfig.*"),
|
|
73
|
-
path2.join(pkg, ".eslintcache")
|
|
74
|
-
];
|
|
55
|
+
const files = [path2.join(pkg, "*.tsbuildinfo"), path2.join(pkg, ".tsconfig.*"), path2.join(pkg, ".eslintcache")];
|
|
75
56
|
for (let file of files) {
|
|
76
57
|
deleteGlob(file);
|
|
77
58
|
}
|
|
78
59
|
return 0;
|
|
79
|
-
}
|
|
60
|
+
};
|
|
80
61
|
|
|
81
62
|
// src/actions/package/clean.ts
|
|
82
|
-
var packageClean =
|
|
83
|
-
return (await Promise.all([
|
|
84
|
-
|
|
85
|
-
packageCleanTypescript()
|
|
86
|
-
])).reduce((prev, value) => prev + value, 0);
|
|
87
|
-
}, "packageClean");
|
|
63
|
+
var packageClean = async () => {
|
|
64
|
+
return (await Promise.all([packageCleanOutputs(), packageCleanTypescript()])).reduce((prev, value) => prev + value, 0);
|
|
65
|
+
};
|
|
88
66
|
|
|
89
67
|
// src/actions/package/compile/compile.ts
|
|
90
68
|
import chalk8 from "chalk";
|
|
@@ -96,38 +74,28 @@ import { build, defineConfig } from "tsup";
|
|
|
96
74
|
// src/actions/package/compile/inputs.ts
|
|
97
75
|
import chalk4 from "chalk";
|
|
98
76
|
import { glob as glob2 } from "glob";
|
|
99
|
-
var getAllInputs =
|
|
100
|
-
return [
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (verbose) {
|
|
115
|
-
console.log(chalk4.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
116
|
-
}
|
|
117
|
-
return result;
|
|
118
|
-
})
|
|
119
|
-
];
|
|
120
|
-
}, "getAllInputs");
|
|
77
|
+
var getAllInputs = (srcDir, verbose = false) => {
|
|
78
|
+
return [...glob2.sync(`${srcDir}/**/*.ts`, { posix: true }).map((file) => {
|
|
79
|
+
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
80
|
+
if (verbose) {
|
|
81
|
+
console.log(chalk4.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}), ...glob2.sync(`${srcDir}/**/*.tsx`, { posix: true }).map((file) => {
|
|
85
|
+
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
86
|
+
if (verbose) {
|
|
87
|
+
console.log(chalk4.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
})];
|
|
91
|
+
};
|
|
121
92
|
|
|
122
93
|
// src/actions/package/compile/buildEntries.ts
|
|
123
|
-
var buildEntries =
|
|
94
|
+
var buildEntries = (srcDir, entryMode = "single", options, excludeSpecAndStories = true, verbose = false) => {
|
|
124
95
|
let entries = [];
|
|
125
96
|
switch (entryMode) {
|
|
126
97
|
case "platform": {
|
|
127
|
-
entries = [
|
|
128
|
-
"index-node.ts",
|
|
129
|
-
"index-browser.ts"
|
|
130
|
-
];
|
|
98
|
+
entries = ["index-node.ts", "index-browser.ts"];
|
|
131
99
|
break;
|
|
132
100
|
}
|
|
133
101
|
case "all": {
|
|
@@ -139,9 +107,7 @@ var buildEntries = /* @__PURE__ */ __name((srcDir, entryMode = "single", options
|
|
|
139
107
|
break;
|
|
140
108
|
}
|
|
141
109
|
default: {
|
|
142
|
-
entries = [
|
|
143
|
-
"index.ts"
|
|
144
|
-
];
|
|
110
|
+
entries = ["index.ts"];
|
|
145
111
|
break;
|
|
146
112
|
}
|
|
147
113
|
}
|
|
@@ -150,7 +116,7 @@ var buildEntries = /* @__PURE__ */ __name((srcDir, entryMode = "single", options
|
|
|
150
116
|
}
|
|
151
117
|
if (verbose) console.log(`buildEntries [${entryMode}] ${entries.length}`);
|
|
152
118
|
return entries;
|
|
153
|
-
}
|
|
119
|
+
};
|
|
154
120
|
|
|
155
121
|
// src/actions/package/compile/deepMerge.ts
|
|
156
122
|
function deepMerge(target, source) {
|
|
@@ -167,7 +133,6 @@ function deepMerge(target, source) {
|
|
|
167
133
|
}
|
|
168
134
|
return target;
|
|
169
135
|
}
|
|
170
|
-
__name(deepMerge, "deepMerge");
|
|
171
136
|
function deepMergeObjects(objects) {
|
|
172
137
|
const result = {};
|
|
173
138
|
for (const obj of objects) {
|
|
@@ -175,30 +140,39 @@ function deepMergeObjects(objects) {
|
|
|
175
140
|
}
|
|
176
141
|
return result;
|
|
177
142
|
}
|
|
178
|
-
__name(deepMergeObjects, "deepMergeObjects");
|
|
179
143
|
|
|
180
144
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
181
145
|
import { cwd as cwd2 } from "process";
|
|
182
146
|
import chalk5 from "chalk";
|
|
183
147
|
import { createProgramFromConfig } from "tsc-prog";
|
|
184
|
-
import ts, {
|
|
148
|
+
import ts, {
|
|
149
|
+
DiagnosticCategory,
|
|
150
|
+
formatDiagnosticsWithColorAndContext,
|
|
151
|
+
getPreEmitDiagnostics,
|
|
152
|
+
sys
|
|
153
|
+
} from "typescript";
|
|
185
154
|
|
|
186
155
|
// src/actions/package/compile/getCompilerOptions.ts
|
|
187
156
|
import { cwd } from "process";
|
|
188
157
|
import deepmerge2 from "deepmerge";
|
|
189
158
|
import { getTsconfig } from "get-tsconfig";
|
|
190
|
-
var getCompilerOptions =
|
|
159
|
+
var getCompilerOptions = (options = {}, fileName = "tsconfig.json") => {
|
|
191
160
|
const resolvedTsConfigCompilerOptions = getTsconfig(cwd(), fileName)?.config?.compilerOptions ?? {};
|
|
192
161
|
return deepmerge2(resolvedTsConfigCompilerOptions, options);
|
|
193
|
-
}
|
|
162
|
+
};
|
|
194
163
|
|
|
195
164
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
196
|
-
var packageCompileTsc =
|
|
165
|
+
var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", compilerOptionsParam, verbose = false) => {
|
|
197
166
|
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
198
167
|
if (verbose) {
|
|
199
168
|
console.log(chalk5.cyan(`Validating code START: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
200
169
|
}
|
|
201
|
-
const configFilePath = ts.findConfigFile(
|
|
170
|
+
const configFilePath = ts.findConfigFile(
|
|
171
|
+
"./",
|
|
172
|
+
// search path
|
|
173
|
+
ts.sys.fileExists,
|
|
174
|
+
"tsconfig.json"
|
|
175
|
+
);
|
|
202
176
|
if (configFilePath === void 0) {
|
|
203
177
|
throw new Error("Could not find tsconfig.json");
|
|
204
178
|
}
|
|
@@ -227,17 +201,18 @@ var packageCompileTsc = /* @__PURE__ */ __name((platform, entries, srcDir = "src
|
|
|
227
201
|
basePath: pkg ?? cwd2(),
|
|
228
202
|
compilerOptions,
|
|
229
203
|
files: entries.map((entry) => `${srcDir}/${entry}`),
|
|
230
|
-
include: [
|
|
231
|
-
`${srcDir}/**/*.*`
|
|
232
|
-
]
|
|
204
|
+
include: [`${srcDir}/**/*.*`]
|
|
233
205
|
});
|
|
234
206
|
const diagnostics = getPreEmitDiagnostics(program);
|
|
235
207
|
if (diagnostics.length > 0) {
|
|
236
|
-
const formattedDiagnostics = formatDiagnosticsWithColorAndContext(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
208
|
+
const formattedDiagnostics = formatDiagnosticsWithColorAndContext(
|
|
209
|
+
diagnostics,
|
|
210
|
+
{
|
|
211
|
+
getCanonicalFileName: (fileName) => fileName,
|
|
212
|
+
getCurrentDirectory: () => srcDir,
|
|
213
|
+
getNewLine: () => sys.newLine
|
|
214
|
+
}
|
|
215
|
+
);
|
|
241
216
|
console.error(formattedDiagnostics);
|
|
242
217
|
}
|
|
243
218
|
program.emit();
|
|
@@ -249,7 +224,7 @@ var packageCompileTsc = /* @__PURE__ */ __name((platform, entries, srcDir = "src
|
|
|
249
224
|
console.log(chalk5.cyan(`Validating code FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
250
225
|
}
|
|
251
226
|
}
|
|
252
|
-
}
|
|
227
|
+
};
|
|
253
228
|
|
|
254
229
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
255
230
|
import path3 from "path";
|
|
@@ -258,31 +233,23 @@ import chalk6 from "chalk";
|
|
|
258
233
|
import { rollup } from "rollup";
|
|
259
234
|
import dts from "rollup-plugin-dts";
|
|
260
235
|
import nodeExternals from "rollup-plugin-node-externals";
|
|
261
|
-
var ignoredWarningCodes = /* @__PURE__ */ new Set([
|
|
262
|
-
"EMPTY_BUNDLE",
|
|
263
|
-
"UNRESOLVED_IMPORT"
|
|
264
|
-
]);
|
|
236
|
+
var ignoredWarningCodes = /* @__PURE__ */ new Set(["EMPTY_BUNDLE", "UNRESOLVED_IMPORT"]);
|
|
265
237
|
async function bundleDts(inputPath, outputPath, platform, options, verbose = false) {
|
|
266
238
|
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
267
239
|
const tsconfigPath = path3.resolve(pkg, "tsconfig.json");
|
|
268
|
-
const nodePlugIns = platform === "node" ? [
|
|
269
|
-
nodeExternals()
|
|
270
|
-
] : [];
|
|
240
|
+
const nodePlugIns = platform === "node" ? [nodeExternals()] : [];
|
|
271
241
|
try {
|
|
272
242
|
const bundle = await rollup({
|
|
273
243
|
input: inputPath,
|
|
274
|
-
plugins: [
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}),
|
|
284
|
-
...nodePlugIns
|
|
285
|
-
],
|
|
244
|
+
plugins: [dts({
|
|
245
|
+
...options,
|
|
246
|
+
tsconfig: tsconfigPath,
|
|
247
|
+
compilerOptions: {
|
|
248
|
+
emitDeclarationOnly: true,
|
|
249
|
+
noEmit: false,
|
|
250
|
+
declarationMap: true
|
|
251
|
+
}
|
|
252
|
+
}), ...nodePlugIns],
|
|
286
253
|
onwarn(warning, warn) {
|
|
287
254
|
if (ignoredWarningCodes.has(warning.code ?? "")) {
|
|
288
255
|
return;
|
|
@@ -305,22 +272,18 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
305
272
|
console.log(`Bundled declarations written to ${outputPath}`);
|
|
306
273
|
}
|
|
307
274
|
}
|
|
308
|
-
|
|
309
|
-
var packageCompileTscTypes = /* @__PURE__ */ __name(async (entries, outDir, platform, srcDir = "build", verbose = false) => {
|
|
275
|
+
var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build", verbose = false) => {
|
|
310
276
|
if (verbose) {
|
|
311
277
|
console.log(chalk6.cyan(`Compiling Types START [${platform}]: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
312
278
|
console.log(`Entries: ${entries.join(", ")}`);
|
|
313
279
|
}
|
|
314
280
|
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
315
281
|
const srcRoot = `${pkg}/${srcDir}/${platform}`;
|
|
316
|
-
const entryNameToTypeName =
|
|
282
|
+
const entryNameToTypeName = (entry) => {
|
|
317
283
|
const splitEntryName = entry.split(".");
|
|
318
284
|
const newEntryExtension = "d." + splitEntryName.at(-1);
|
|
319
|
-
return [
|
|
320
|
-
|
|
321
|
-
newEntryExtension
|
|
322
|
-
].join(".");
|
|
323
|
-
}, "entryNameToTypeName");
|
|
285
|
+
return [...splitEntryName.slice(0, -1), newEntryExtension].join(".");
|
|
286
|
+
};
|
|
324
287
|
const compilerOptions = getCompilerOptions({
|
|
325
288
|
removeComments: false,
|
|
326
289
|
skipDefaultLibCheck: true,
|
|
@@ -332,18 +295,16 @@ var packageCompileTscTypes = /* @__PURE__ */ __name(async (entries, outDir, plat
|
|
|
332
295
|
const entryNames = entries.map((entry) => entry.split(`${srcDir}/`).at(-1) ?? entry);
|
|
333
296
|
await Promise.all(entryNames.map(async (entryName) => {
|
|
334
297
|
const entryTypeName = entryNameToTypeName(entryName);
|
|
335
|
-
await bundleDts(`${srcRoot}/${entryTypeName}`, `${outDir}/${entryTypeName}`, platform, {
|
|
336
|
-
compilerOptions
|
|
337
|
-
}, verbose);
|
|
298
|
+
await bundleDts(`${srcRoot}/${entryTypeName}`, `${outDir}/${entryTypeName}`, platform, { compilerOptions }, verbose);
|
|
338
299
|
}));
|
|
339
300
|
if (verbose) {
|
|
340
301
|
console.log(chalk6.cyan(`Compiling Types FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
341
302
|
}
|
|
342
303
|
return 0;
|
|
343
|
-
}
|
|
304
|
+
};
|
|
344
305
|
|
|
345
306
|
// src/actions/package/compile/packageCompileTsup.ts
|
|
346
|
-
var compileFolder =
|
|
307
|
+
var compileFolder = async (srcDir, entries, buildDir, options, bundleTypes = false, verbose) => {
|
|
347
308
|
const outDir = options?.outDir ?? "dist";
|
|
348
309
|
if (verbose) {
|
|
349
310
|
console.log(`compileFolder [${srcDir}, ${options?.outDir}]`);
|
|
@@ -360,35 +321,27 @@ var compileFolder = /* @__PURE__ */ __name(async (srcDir, entries, buildDir, opt
|
|
|
360
321
|
console.error(chalk7.red(`Compile:Validation had ${validationResult} errors`));
|
|
361
322
|
return validationResult;
|
|
362
323
|
}
|
|
363
|
-
const optionsParams = tsupOptions([
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
...options,
|
|
378
|
-
entry: entries.map((entry) => `${srcDir}/${entry}`)
|
|
379
|
-
}
|
|
380
|
-
]);
|
|
324
|
+
const optionsParams = tsupOptions([{
|
|
325
|
+
bundle: true,
|
|
326
|
+
cjsInterop: true,
|
|
327
|
+
clean: false,
|
|
328
|
+
dts: false,
|
|
329
|
+
format: ["esm"],
|
|
330
|
+
outDir,
|
|
331
|
+
silent: true,
|
|
332
|
+
sourcemap: true,
|
|
333
|
+
splitting: false,
|
|
334
|
+
tsconfig: "tsconfig.json",
|
|
335
|
+
...options,
|
|
336
|
+
entry: entries.map((entry) => `${srcDir}/${entry}`)
|
|
337
|
+
}]);
|
|
381
338
|
const optionsResult = defineConfig(optionsParams);
|
|
382
|
-
const optionsList = (await Promise.all(
|
|
383
|
-
optionsResult
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
return Array.isArray(result) ? result : [
|
|
389
|
-
result
|
|
390
|
-
];
|
|
391
|
-
}))).flat();
|
|
339
|
+
const optionsList = (await Promise.all(
|
|
340
|
+
(Array.isArray(optionsResult) ? optionsResult : [optionsResult]).flatMap(async (options2) => {
|
|
341
|
+
const result = typeof options2 === "function" ? await options2({}) : [options2];
|
|
342
|
+
return Array.isArray(result) ? result : [result];
|
|
343
|
+
})
|
|
344
|
+
)).flat();
|
|
392
345
|
if (verbose) {
|
|
393
346
|
console.log(chalk7.cyan(`TSUP:build:start [${srcDir}]`));
|
|
394
347
|
console.log(chalk7.gray(`TSUP:build:options [${JSON.stringify(optionsList, null, 2)}]`));
|
|
@@ -401,8 +354,8 @@ var compileFolder = /* @__PURE__ */ __name(async (srcDir, entries, buildDir, opt
|
|
|
401
354
|
await packageCompileTscTypes(entries, outDir, options?.platform ?? "neutral", buildDir, verbose);
|
|
402
355
|
}
|
|
403
356
|
return 0;
|
|
404
|
-
}
|
|
405
|
-
var tsupOptions =
|
|
357
|
+
};
|
|
358
|
+
var tsupOptions = (options = []) => {
|
|
406
359
|
const standardLoaders = {
|
|
407
360
|
".gif": "copy",
|
|
408
361
|
".html": "copy",
|
|
@@ -414,25 +367,16 @@ var tsupOptions = /* @__PURE__ */ __name((options = []) => {
|
|
|
414
367
|
};
|
|
415
368
|
const standardOptions = {
|
|
416
369
|
bundle: true,
|
|
417
|
-
format: [
|
|
418
|
-
"esm"
|
|
419
|
-
],
|
|
370
|
+
format: ["esm"],
|
|
420
371
|
loader: standardLoaders,
|
|
421
|
-
outExtension:
|
|
422
|
-
js: ".mjs"
|
|
423
|
-
} : {
|
|
424
|
-
js: ".cjs"
|
|
425
|
-
}, "outExtension"),
|
|
372
|
+
outExtension: ({ format }) => format === "esm" ? { js: ".mjs" } : { js: ".cjs" },
|
|
426
373
|
skipNodeModulesBundle: true,
|
|
427
374
|
sourcemap: true,
|
|
428
375
|
target: "esnext"
|
|
429
376
|
};
|
|
430
|
-
return deepMergeObjects([
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
]);
|
|
434
|
-
}, "tsupOptions");
|
|
435
|
-
var packageCompileTsup = /* @__PURE__ */ __name(async (config2) => {
|
|
377
|
+
return deepMergeObjects([standardOptions, ...options]);
|
|
378
|
+
};
|
|
379
|
+
var packageCompileTsup = async (config2) => {
|
|
436
380
|
const compile = config2?.compile;
|
|
437
381
|
const verbose = config2?.verbose ?? false;
|
|
438
382
|
const outDirAsBuildDir = compile?.outDirAsBuildDir ?? true;
|
|
@@ -440,94 +384,100 @@ var packageCompileTsup = /* @__PURE__ */ __name(async (config2) => {
|
|
|
440
384
|
if (verbose) {
|
|
441
385
|
console.log("Compiling with TSUP");
|
|
442
386
|
}
|
|
443
|
-
const compileForNode = compile?.node ?? {
|
|
444
|
-
|
|
445
|
-
};
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
compile?.
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
387
|
+
const compileForNode = compile?.node ?? { src: {} };
|
|
388
|
+
const compileForBrowser = compile?.browser ?? { src: {} };
|
|
389
|
+
const compileForNeutral = compile?.neutral ?? { src: {} };
|
|
390
|
+
return (await Promise.all(
|
|
391
|
+
Object.entries(compileForNode).map(async ([srcDir, options]) => {
|
|
392
|
+
const optionsObject = typeof options === "object" ? options : {};
|
|
393
|
+
const inEsBuildOptions = typeof compile?.node?.esbuildOptions === "object" ? compile?.node?.esbuildOptions : {};
|
|
394
|
+
const entry = buildEntries(srcDir, compile?.entryMode, options, true, verbose);
|
|
395
|
+
const platform = "node";
|
|
396
|
+
const rootOutDir = optionsObject.outDir ?? "dist";
|
|
397
|
+
const outDir = rootOutDir + "/" + platform;
|
|
398
|
+
return typeof srcDir === "string" ? await compileFolder(
|
|
399
|
+
srcDir,
|
|
400
|
+
entry,
|
|
401
|
+
outDirAsBuildDir ? rootOutDir : "build",
|
|
402
|
+
tsupOptions([
|
|
403
|
+
inEsBuildOptions,
|
|
404
|
+
compile?.tsup?.options ?? {},
|
|
405
|
+
typeof options === "object" ? options : {},
|
|
406
|
+
{ platform: "node", outDir }
|
|
407
|
+
]),
|
|
408
|
+
bundleTypes,
|
|
409
|
+
verbose
|
|
410
|
+
) : 0;
|
|
411
|
+
})
|
|
412
|
+
)).reduce((prev, value) => prev + value, 0) + (await Promise.all(
|
|
413
|
+
Object.entries(compileForBrowser).map(async ([srcDir, options]) => {
|
|
414
|
+
const optionsObject = typeof options === "object" ? options : {};
|
|
415
|
+
const inEsBuildOptions = typeof compile?.browser?.esbuildOptions === "object" ? compile?.browser?.esbuildOptions : {};
|
|
416
|
+
const entry = buildEntries(srcDir, compile?.entryMode, options, true, verbose);
|
|
417
|
+
const platform = "browser";
|
|
418
|
+
const rootOutDir = optionsObject.outDir ?? "dist";
|
|
419
|
+
const outDir = rootOutDir + "/" + platform;
|
|
420
|
+
return typeof srcDir === "string" ? await compileFolder(
|
|
421
|
+
srcDir,
|
|
422
|
+
entry,
|
|
423
|
+
outDirAsBuildDir ? rootOutDir : "build",
|
|
424
|
+
tsupOptions([
|
|
425
|
+
inEsBuildOptions,
|
|
426
|
+
compile?.tsup?.options ?? {},
|
|
427
|
+
typeof options === "object" ? options : {},
|
|
428
|
+
{ platform: "browser", outDir }
|
|
429
|
+
]),
|
|
430
|
+
bundleTypes,
|
|
431
|
+
verbose
|
|
432
|
+
) : 0;
|
|
433
|
+
})
|
|
434
|
+
)).reduce((prev, value) => prev + value, 0) + (await Promise.all(
|
|
435
|
+
Object.entries(compileForNeutral).map(async ([srcDir, options]) => {
|
|
436
|
+
const optionsObject = typeof options === "object" ? options : {};
|
|
437
|
+
const inEsBuildOptions = typeof compile?.neutral?.esbuildOptions === "object" ? compile?.neutral?.esbuildOptions : {};
|
|
438
|
+
const entry = buildEntries(srcDir, compile?.entryMode, options, true, verbose);
|
|
439
|
+
const platform = "neutral";
|
|
440
|
+
const rootOutDir = optionsObject.outDir ?? "dist";
|
|
441
|
+
const outDir = rootOutDir + "/" + platform;
|
|
442
|
+
return typeof srcDir === "string" ? await compileFolder(
|
|
443
|
+
srcDir,
|
|
444
|
+
entry,
|
|
445
|
+
outDirAsBuildDir ? rootOutDir : "build",
|
|
446
|
+
tsupOptions([
|
|
447
|
+
inEsBuildOptions,
|
|
448
|
+
compile?.tsup?.options ?? {},
|
|
449
|
+
typeof options === "object" ? options : {},
|
|
450
|
+
{ platform: "neutral", outDir }
|
|
451
|
+
]),
|
|
452
|
+
bundleTypes,
|
|
453
|
+
verbose
|
|
454
|
+
) : 0;
|
|
455
|
+
})
|
|
456
|
+
)).reduce((prev, value) => prev + value, 0) + 0;
|
|
457
|
+
};
|
|
502
458
|
|
|
503
459
|
// src/actions/package/compile/compile.ts
|
|
504
|
-
var packageCompile =
|
|
460
|
+
var packageCompile = async (inConfig = {}) => {
|
|
505
461
|
const pkg = process.env.INIT_CWD;
|
|
506
462
|
console.log(chalk8.green(`Compiling ${pkg}`));
|
|
507
463
|
const config2 = await loadConfig(inConfig);
|
|
508
464
|
return await packageCompileTsup(config2);
|
|
509
|
-
}
|
|
465
|
+
};
|
|
510
466
|
|
|
511
467
|
// src/actions/package/copy-assets.ts
|
|
512
468
|
import path4 from "path/posix";
|
|
513
469
|
import chalk9 from "chalk";
|
|
514
470
|
import cpy from "cpy";
|
|
515
|
-
var copyTargetAssets =
|
|
471
|
+
var copyTargetAssets = async (target, name, location) => {
|
|
516
472
|
try {
|
|
517
|
-
const values = await cpy(
|
|
518
|
-
"**/*.jpg",
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
"**/*.gif",
|
|
526
|
-
"**/*.css"
|
|
527
|
-
], `../dist/${target}`, {
|
|
528
|
-
cwd: path4.join(location, "src"),
|
|
529
|
-
flat: false
|
|
530
|
-
});
|
|
473
|
+
const values = await cpy(
|
|
474
|
+
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
475
|
+
`../dist/${target}`,
|
|
476
|
+
{
|
|
477
|
+
cwd: path4.join(location, "src"),
|
|
478
|
+
flat: false
|
|
479
|
+
}
|
|
480
|
+
);
|
|
531
481
|
if (values.length > 0) {
|
|
532
482
|
console.log(chalk9.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
|
|
533
483
|
}
|
|
@@ -540,8 +490,8 @@ var copyTargetAssets = /* @__PURE__ */ __name(async (target, name, location) =>
|
|
|
540
490
|
console.log(`Copy Assets Failed: ${name}: ${error.message}`);
|
|
541
491
|
return 1;
|
|
542
492
|
}
|
|
543
|
-
}
|
|
544
|
-
var packageCopyAssets =
|
|
493
|
+
};
|
|
494
|
+
var packageCopyAssets = async ({ target }) => {
|
|
545
495
|
const pkg = process.env.INIT_CWD ?? "./";
|
|
546
496
|
const pkgName = process.env.npm_package_name ?? "Unknown";
|
|
547
497
|
switch (target) {
|
|
@@ -555,11 +505,11 @@ var packageCopyAssets = /* @__PURE__ */ __name(async ({ target }) => {
|
|
|
555
505
|
return await copyTargetAssets("esm", pkgName, pkg) || await copyTargetAssets("cjs", pkgName, pkg);
|
|
556
506
|
}
|
|
557
507
|
}
|
|
558
|
-
}
|
|
508
|
+
};
|
|
559
509
|
|
|
560
510
|
// src/actions/package/cycle.ts
|
|
561
511
|
import { cruise } from "dependency-cruiser";
|
|
562
|
-
var packageCycle =
|
|
512
|
+
var packageCycle = async () => {
|
|
563
513
|
const pkg = process.env.INIT_CWD;
|
|
564
514
|
const pkgName = process.env.npm_package_name;
|
|
565
515
|
const cruiseOptions = {
|
|
@@ -570,26 +520,20 @@ var packageCycle = /* @__PURE__ */ __name(async () => {
|
|
|
570
520
|
severity: "error",
|
|
571
521
|
comment: "This dependency creates a circular reference",
|
|
572
522
|
from: {},
|
|
573
|
-
to: {
|
|
574
|
-
circular: true
|
|
575
|
-
}
|
|
523
|
+
to: { circular: true }
|
|
576
524
|
}
|
|
577
525
|
]
|
|
578
526
|
},
|
|
579
527
|
exclude: "node_modules|packages/.*/packages",
|
|
580
528
|
validate: true,
|
|
581
|
-
doNotFollow: {
|
|
582
|
-
path: "node_modules|packages/.*/packages"
|
|
583
|
-
},
|
|
529
|
+
doNotFollow: { path: "node_modules|packages/.*/packages" },
|
|
584
530
|
tsPreCompilationDeps: false,
|
|
585
531
|
combinedDependencies: true,
|
|
586
532
|
outputType: "err"
|
|
587
533
|
};
|
|
588
534
|
const target = `${pkg}/src`;
|
|
589
535
|
console.log(`Checking for circular dependencies in ${target}...`);
|
|
590
|
-
const result = await cruise([
|
|
591
|
-
target
|
|
592
|
-
], cruiseOptions);
|
|
536
|
+
const result = await cruise([target], cruiseOptions);
|
|
593
537
|
console.log(result.output);
|
|
594
538
|
if (result.exitCode === 0) {
|
|
595
539
|
console.log(`${pkgName} \u2705 No dependency violations`);
|
|
@@ -597,13 +541,18 @@ var packageCycle = /* @__PURE__ */ __name(async () => {
|
|
|
597
541
|
console.error(`${pkgName} \u274C Dependency violations found`);
|
|
598
542
|
}
|
|
599
543
|
return result.exitCode;
|
|
600
|
-
}
|
|
544
|
+
};
|
|
601
545
|
|
|
602
546
|
// src/actions/package/gen-docs.ts
|
|
603
547
|
import { existsSync } from "fs";
|
|
604
548
|
import path5 from "path";
|
|
605
549
|
import chalk10 from "chalk";
|
|
606
|
-
import {
|
|
550
|
+
import {
|
|
551
|
+
Application,
|
|
552
|
+
ArgumentsReader,
|
|
553
|
+
TSConfigReader,
|
|
554
|
+
TypeDocReader
|
|
555
|
+
} from "typedoc";
|
|
607
556
|
var ExitCodes = {
|
|
608
557
|
CompileError: 3,
|
|
609
558
|
ExceptionThrown: 6,
|
|
@@ -613,17 +562,14 @@ var ExitCodes = {
|
|
|
613
562
|
OutputError: 5,
|
|
614
563
|
ValidationError: 4
|
|
615
564
|
};
|
|
616
|
-
var packageGenDocs =
|
|
565
|
+
var packageGenDocs = async () => {
|
|
617
566
|
const pkg = process.env.INIT_CWD;
|
|
618
567
|
if (pkg !== void 0 && !existsSync(path5.join(pkg, "typedoc.json"))) {
|
|
619
568
|
return;
|
|
620
569
|
}
|
|
621
570
|
const app = await Application.bootstrap({
|
|
622
571
|
entryPointStrategy: "merge",
|
|
623
|
-
entryPoints: [
|
|
624
|
-
`${pkg}/src/**/*.ts`,
|
|
625
|
-
`${pkg}/packages/*/dist/docs.json`
|
|
626
|
-
],
|
|
572
|
+
entryPoints: [`${pkg}/src/**/*.ts`, `${pkg}/packages/*/dist/docs.json`],
|
|
627
573
|
excludeExternals: true,
|
|
628
574
|
json: `${pkg}/dist/docs.json`,
|
|
629
575
|
logLevel: "Error",
|
|
@@ -634,8 +580,8 @@ var packageGenDocs = /* @__PURE__ */ __name(async () => {
|
|
|
634
580
|
app.options.addReader(new TSConfigReader());
|
|
635
581
|
app.options.addReader(new ArgumentsReader(300));
|
|
636
582
|
return await runTypeDoc(app);
|
|
637
|
-
}
|
|
638
|
-
var runTypeDoc =
|
|
583
|
+
};
|
|
584
|
+
var runTypeDoc = async (app) => {
|
|
639
585
|
const pkgName = process.env.npm_package_name;
|
|
640
586
|
if (app.options.getValue("version")) {
|
|
641
587
|
console.log(app.toString());
|
|
@@ -706,7 +652,7 @@ var runTypeDoc = /* @__PURE__ */ __name(async (app) => {
|
|
|
706
652
|
}
|
|
707
653
|
console.log(chalk10.green(`${pkgName} - Ok`));
|
|
708
654
|
return ExitCodes.Ok;
|
|
709
|
-
}
|
|
655
|
+
};
|
|
710
656
|
|
|
711
657
|
// src/actions/package/lint.ts
|
|
712
658
|
import { readdirSync } from "fs";
|
|
@@ -717,27 +663,24 @@ import chalk11 from "chalk";
|
|
|
717
663
|
import { ESLint } from "eslint";
|
|
718
664
|
import { findUp } from "find-up";
|
|
719
665
|
import picomatch from "picomatch";
|
|
720
|
-
var dumpMessages =
|
|
721
|
-
const colors = [
|
|
722
|
-
|
|
723
|
-
"yellow",
|
|
724
|
-
"red"
|
|
725
|
-
];
|
|
726
|
-
const severity = [
|
|
727
|
-
"none",
|
|
728
|
-
"warning",
|
|
729
|
-
"error"
|
|
730
|
-
];
|
|
666
|
+
var dumpMessages = (lintResults) => {
|
|
667
|
+
const colors = ["white", "yellow", "red"];
|
|
668
|
+
const severity = ["none", "warning", "error"];
|
|
731
669
|
for (const lintResult of lintResults) {
|
|
732
670
|
if (lintResult.messages.length > 0) {
|
|
733
671
|
console.log(chalk11.gray(`
|
|
734
672
|
${lintResult.filePath}`));
|
|
735
673
|
for (const message of lintResult.messages) {
|
|
736
|
-
console.log(
|
|
674
|
+
console.log(
|
|
675
|
+
chalk11.gray(` ${message.line}:${message.column}`),
|
|
676
|
+
chalk11[colors[message.severity]](` ${severity[message.severity]}`),
|
|
677
|
+
chalk11.white(` ${message.message}`),
|
|
678
|
+
chalk11.gray(` ${message.ruleId}`)
|
|
679
|
+
);
|
|
737
680
|
}
|
|
738
681
|
}
|
|
739
682
|
}
|
|
740
|
-
}
|
|
683
|
+
};
|
|
741
684
|
async function getRootESLintConfig() {
|
|
742
685
|
const configPath = await findUp("eslint.config.mjs");
|
|
743
686
|
if (configPath === void 0) {
|
|
@@ -745,43 +688,26 @@ async function getRootESLintConfig() {
|
|
|
745
688
|
}
|
|
746
689
|
return pathToFileURL(configPath);
|
|
747
690
|
}
|
|
748
|
-
__name(getRootESLintConfig, "getRootESLintConfig");
|
|
749
691
|
function getFiles(dir, ignoreFolders) {
|
|
750
692
|
const currentDirectory = cwd4();
|
|
751
693
|
const subDirectory = dir.split(currentDirectory)[1];
|
|
752
694
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
753
|
-
return readdirSync(dir, {
|
|
754
|
-
withFileTypes: true
|
|
755
|
-
}).flatMap((dirent) => {
|
|
695
|
+
return readdirSync(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
756
696
|
const res = path6.resolve(dir, dirent.name);
|
|
757
697
|
const relativePath = subDirectory === void 0 ? dirent.name : `${subDirectory}/${dirent.name}`;
|
|
758
698
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
759
699
|
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
760
|
-
return dirent.isDirectory() ? getFiles(res, ignoreFolders) : [
|
|
761
|
-
res
|
|
762
|
-
];
|
|
700
|
+
return dirent.isDirectory() ? getFiles(res, ignoreFolders) : [res];
|
|
763
701
|
});
|
|
764
702
|
}
|
|
765
|
-
|
|
766
|
-
var packageLint = /* @__PURE__ */ __name(async (fix = false, verbose = false, cache = true) => {
|
|
703
|
+
var packageLint = async (fix = false, verbose = false, cache = true) => {
|
|
767
704
|
const pkg = process.env.INIT_CWD;
|
|
768
705
|
const configPath = await getRootESLintConfig();
|
|
769
706
|
const { default: eslintConfig } = await import(configPath.href);
|
|
770
707
|
const start = Date.now();
|
|
771
|
-
const ignoreFolders = [
|
|
772
|
-
"node_modules",
|
|
773
|
-
"dist",
|
|
774
|
-
"packages",
|
|
775
|
-
".git",
|
|
776
|
-
"build",
|
|
777
|
-
".yarn",
|
|
778
|
-
".vscode",
|
|
779
|
-
".github"
|
|
780
|
-
];
|
|
708
|
+
const ignoreFolders = ["node_modules", "dist", "packages", ".git", "build", ".yarn", ".vscode", ".github"];
|
|
781
709
|
const engine = new ESLint({
|
|
782
|
-
baseConfig: [
|
|
783
|
-
...eslintConfig
|
|
784
|
-
],
|
|
710
|
+
baseConfig: [...eslintConfig],
|
|
785
711
|
fix,
|
|
786
712
|
warnIgnored: false,
|
|
787
713
|
cache
|
|
@@ -800,33 +726,35 @@ var packageLint = /* @__PURE__ */ __name(async (fix = false, verbose = false, ca
|
|
|
800
726
|
const lintTimeColor = lintTime < 1e3 ? "green" : lintTime < 3e3 ? "yellow" : "red";
|
|
801
727
|
console.log(chalk11.white(`Linted ${chalk11[filesCountColor](files.length)} files in ${chalk11[lintTimeColor](lintTime)}ms`));
|
|
802
728
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
803
|
-
}
|
|
729
|
+
};
|
|
804
730
|
|
|
805
731
|
// src/actions/package/publint.ts
|
|
806
732
|
import { promises as fs2 } from "fs";
|
|
807
733
|
import chalk12 from "chalk";
|
|
808
734
|
import sortPackageJson from "sort-package-json";
|
|
809
|
-
var customPubLint =
|
|
735
|
+
var customPubLint = (pkg) => {
|
|
810
736
|
let errorCount = 0;
|
|
811
737
|
let warningCount = 0;
|
|
812
738
|
if (pkg.files === void 0) {
|
|
813
|
-
console.
|
|
739
|
+
console.warn(chalk12.yellow('Publint [custom]: "files" field is missing'));
|
|
814
740
|
warningCount++;
|
|
815
741
|
}
|
|
816
742
|
if (pkg.main !== void 0) {
|
|
817
|
-
console.
|
|
743
|
+
console.warn(chalk12.yellow('Publint [custom]: "main" field is deprecated, use "exports" instead'));
|
|
818
744
|
warningCount++;
|
|
819
745
|
}
|
|
820
746
|
if (pkg.sideEffects !== false) {
|
|
821
|
-
console.
|
|
747
|
+
console.warn(chalk12.yellow('Publint [custom]: "sideEffects" field should be set to false'));
|
|
748
|
+
warningCount++;
|
|
749
|
+
}
|
|
750
|
+
if (pkg.resolutions !== void 0) {
|
|
751
|
+
console.warn(chalk12.yellow('Publint [custom]: "resolutions" in use'));
|
|
752
|
+
console.warn(chalk12.gray(JSON.stringify(pkg.resolutions, null, 2)));
|
|
822
753
|
warningCount++;
|
|
823
754
|
}
|
|
824
|
-
return [
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
];
|
|
828
|
-
}, "customPubLint");
|
|
829
|
-
var packagePublint = /* @__PURE__ */ __name(async ({ strict = true, verbose = false } = {}) => {
|
|
755
|
+
return [errorCount, warningCount];
|
|
756
|
+
};
|
|
757
|
+
var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
830
758
|
const pkgDir = process.env.INIT_CWD;
|
|
831
759
|
const sortedPkg = sortPackageJson(await fs2.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
832
760
|
await fs2.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
@@ -861,12 +789,12 @@ var packagePublint = /* @__PURE__ */ __name(async ({ strict = true, verbose = fa
|
|
|
861
789
|
console.log(chalk12.gray(`Publint [Finish]: ${pkgDir} [${messages.length + errorCount + warningCount} messages]`));
|
|
862
790
|
}
|
|
863
791
|
return messages.filter((message) => message.type === "error").length + errorCount;
|
|
864
|
-
}
|
|
792
|
+
};
|
|
865
793
|
|
|
866
794
|
// src/actions/package/recompile.ts
|
|
867
|
-
var packageRecompile =
|
|
795
|
+
var packageRecompile = async () => {
|
|
868
796
|
return await packageClean() || await packageCompile();
|
|
869
|
-
}
|
|
797
|
+
};
|
|
870
798
|
export {
|
|
871
799
|
bundleDts,
|
|
872
800
|
packageClean,
|