@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,274 +175,361 @@ 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(
|
|
441
|
+
console.log("Compiling with TSUP");
|
|
270
442
|
}
|
|
271
|
-
const compileForNode = compile?.node ?? {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
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
|
-
};
|
|
340
|
-
|
|
341
|
-
// src/actions/package/compile/packageCompileTsc.ts
|
|
342
|
-
import { cwd as cwd2 } from "process";
|
|
343
|
-
import chalk6 from "chalk";
|
|
344
|
-
import { createProgramFromConfig } from "tsc-prog";
|
|
345
|
-
import {
|
|
346
|
-
DiagnosticCategory,
|
|
347
|
-
formatDiagnosticsWithColorAndContext,
|
|
348
|
-
getPreEmitDiagnostics,
|
|
349
|
-
sys as sys2
|
|
350
|
-
} from "typescript";
|
|
351
|
-
|
|
352
|
-
// src/actions/package/compile/getCompilerOptions.ts
|
|
353
|
-
import { createRequire } from "module";
|
|
354
|
-
import deepmerge2 from "deepmerge";
|
|
355
|
-
import {
|
|
356
|
-
findConfigFile,
|
|
357
|
-
readConfigFile,
|
|
358
|
-
sys
|
|
359
|
-
} from "typescript";
|
|
360
|
-
var getNested = (config2) => {
|
|
361
|
-
if (config2.extends) {
|
|
362
|
-
const require2 = createRequire(import.meta.url);
|
|
363
|
-
const opts = require2(config2.extends);
|
|
364
|
-
return deepmerge2(getNested(opts), config2.compilerOptions ?? {});
|
|
365
|
-
}
|
|
366
|
-
return config2.compilerOptions;
|
|
367
|
-
};
|
|
368
|
-
var getCompilerOptionsJSONFollowExtends = (filename) => {
|
|
369
|
-
const config2 = readConfigFile(filename, sys.readFile).config;
|
|
370
|
-
return getNested(config2);
|
|
371
|
-
};
|
|
372
|
-
var getCompilerOptions = (options = {}, tsconfig = "tsconfig.json") => {
|
|
373
|
-
const configFileName = findConfigFile("./", sys.fileExists, tsconfig);
|
|
374
|
-
const configFileCompilerOptions = (configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : void 0) ?? {};
|
|
375
|
-
return deepmerge2(configFileCompilerOptions, options);
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
// src/actions/package/compile/packageCompileTsc.ts
|
|
379
|
-
var packageCompileTsc = (folder = "src", config2 = {}, compilerOptionsParam) => {
|
|
380
|
-
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
381
|
-
const verbose = config2?.verbose ?? false;
|
|
382
|
-
const compilerOptions = {
|
|
383
|
-
...getCompilerOptions({
|
|
384
|
-
outDir: "dist/types",
|
|
385
|
-
removeComments: false,
|
|
386
|
-
skipDefaultLibCheck: true,
|
|
387
|
-
skipLibCheck: true,
|
|
388
|
-
sourceMap: false
|
|
389
|
-
}),
|
|
390
|
-
...compilerOptionsParam,
|
|
391
|
-
emitDeclarationOnly: false,
|
|
392
|
-
noEmit: true
|
|
393
|
-
};
|
|
394
|
-
const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
|
|
395
|
-
const includes = [".stories.", ".spec.", ".d.ts", ".d.cts", ".d.mts"];
|
|
396
|
-
const files = buildEntries(folder, "all", {}, true, verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && includes.find((include) => file.includes(include)));
|
|
397
|
-
console.log(chalk6.green(`Compiling Files ${pkg}: ${files.length}`));
|
|
398
|
-
if (files.length > 0) {
|
|
399
|
-
const program = createProgramFromConfig({
|
|
400
|
-
basePath: pkg ?? cwd2(),
|
|
401
|
-
compilerOptions,
|
|
402
|
-
exclude: ["dist", "docs"],
|
|
403
|
-
files
|
|
404
|
-
});
|
|
405
|
-
const diagnostics = getPreEmitDiagnostics(program);
|
|
406
|
-
if (diagnostics.length > 0) {
|
|
407
|
-
const formattedDiagnostics = formatDiagnosticsWithColorAndContext(
|
|
408
|
-
diagnostics,
|
|
409
|
-
{
|
|
410
|
-
getCanonicalFileName: (fileName) => fileName,
|
|
411
|
-
getCurrentDirectory: () => folder,
|
|
412
|
-
getNewLine: () => sys2.newLine
|
|
413
|
-
}
|
|
414
|
-
);
|
|
415
|
-
console.error(formattedDiagnostics);
|
|
416
|
-
}
|
|
417
|
-
program.emit();
|
|
418
|
-
return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0);
|
|
419
|
-
}
|
|
420
|
-
return 0;
|
|
421
|
-
};
|
|
508
|
+
return await packageCompileTsup(config2);
|
|
509
|
+
}, "packageCompile");
|
|
422
510
|
|
|
423
511
|
// src/actions/package/copy-assets.ts
|
|
424
|
-
import
|
|
425
|
-
import
|
|
512
|
+
import path4 from "path/posix";
|
|
513
|
+
import chalk9 from "chalk";
|
|
426
514
|
import cpy from "cpy";
|
|
427
|
-
var copyTargetAssets = async (target, name, location) => {
|
|
515
|
+
var copyTargetAssets = /* @__PURE__ */ __name(async (target, name, location) => {
|
|
428
516
|
try {
|
|
429
|
-
const values = await cpy(
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
517
|
+
const values = await cpy([
|
|
518
|
+
"**/*.jpg",
|
|
519
|
+
"**/*.png",
|
|
520
|
+
"**/*.gif",
|
|
521
|
+
"**/*.svg",
|
|
522
|
+
"**/*.webp",
|
|
523
|
+
"**/*.sass",
|
|
524
|
+
"**/*.scss",
|
|
525
|
+
"**/*.gif",
|
|
526
|
+
"**/*.css"
|
|
527
|
+
], `../dist/${target}`, {
|
|
528
|
+
cwd: path4.join(location, "src"),
|
|
529
|
+
flat: false
|
|
530
|
+
});
|
|
437
531
|
if (values.length > 0) {
|
|
438
|
-
console.log(
|
|
532
|
+
console.log(chalk9.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
|
|
439
533
|
}
|
|
440
534
|
for (const value of values) {
|
|
441
535
|
console.log(`${value.split("/").pop()} => ./dist/${target}`);
|
|
@@ -446,8 +540,8 @@ var copyTargetAssets = async (target, name, location) => {
|
|
|
446
540
|
console.log(`Copy Assets Failed: ${name}: ${error.message}`);
|
|
447
541
|
return 1;
|
|
448
542
|
}
|
|
449
|
-
};
|
|
450
|
-
var packageCopyAssets = async ({ target }) => {
|
|
543
|
+
}, "copyTargetAssets");
|
|
544
|
+
var packageCopyAssets = /* @__PURE__ */ __name(async ({ target }) => {
|
|
451
545
|
const pkg = process.env.INIT_CWD ?? "./";
|
|
452
546
|
const pkgName = process.env.npm_package_name ?? "Unknown";
|
|
453
547
|
switch (target) {
|
|
@@ -461,11 +555,11 @@ var packageCopyAssets = async ({ target }) => {
|
|
|
461
555
|
return await copyTargetAssets("esm", pkgName, pkg) || await copyTargetAssets("cjs", pkgName, pkg);
|
|
462
556
|
}
|
|
463
557
|
}
|
|
464
|
-
};
|
|
558
|
+
}, "packageCopyAssets");
|
|
465
559
|
|
|
466
560
|
// src/actions/package/cycle.ts
|
|
467
561
|
import { cruise } from "dependency-cruiser";
|
|
468
|
-
var packageCycle =
|
|
562
|
+
var packageCycle = /* @__PURE__ */ __name(async () => {
|
|
469
563
|
const pkg = process.env.INIT_CWD;
|
|
470
564
|
const pkgName = process.env.npm_package_name;
|
|
471
565
|
const cruiseOptions = {
|
|
@@ -476,41 +570,40 @@ var packageCycle = async ({ verbose = false }) => {
|
|
|
476
570
|
severity: "error",
|
|
477
571
|
comment: "This dependency creates a circular reference",
|
|
478
572
|
from: {},
|
|
479
|
-
to: {
|
|
573
|
+
to: {
|
|
574
|
+
circular: true
|
|
575
|
+
}
|
|
480
576
|
}
|
|
481
577
|
]
|
|
482
578
|
},
|
|
483
579
|
exclude: "node_modules|packages/.*/packages",
|
|
484
580
|
validate: true,
|
|
485
|
-
doNotFollow: {
|
|
581
|
+
doNotFollow: {
|
|
582
|
+
path: "node_modules|packages/.*/packages"
|
|
583
|
+
},
|
|
486
584
|
tsPreCompilationDeps: false,
|
|
487
585
|
combinedDependencies: true,
|
|
488
|
-
outputType:
|
|
586
|
+
outputType: "err"
|
|
489
587
|
};
|
|
490
588
|
const target = `${pkg}/src`;
|
|
491
589
|
console.log(`Checking for circular dependencies in ${target}...`);
|
|
492
|
-
const result = await cruise([
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
590
|
+
const result = await cruise([
|
|
591
|
+
target
|
|
592
|
+
], cruiseOptions);
|
|
593
|
+
console.log(result.output);
|
|
496
594
|
if (result.exitCode === 0) {
|
|
497
595
|
console.log(`${pkgName} \u2705 No dependency violations`);
|
|
498
596
|
} else {
|
|
499
597
|
console.error(`${pkgName} \u274C Dependency violations found`);
|
|
500
598
|
}
|
|
501
599
|
return result.exitCode;
|
|
502
|
-
};
|
|
600
|
+
}, "packageCycle");
|
|
503
601
|
|
|
504
602
|
// src/actions/package/gen-docs.ts
|
|
505
603
|
import { existsSync } from "fs";
|
|
506
|
-
import
|
|
507
|
-
import
|
|
508
|
-
import {
|
|
509
|
-
Application,
|
|
510
|
-
ArgumentsReader,
|
|
511
|
-
TSConfigReader,
|
|
512
|
-
TypeDocReader
|
|
513
|
-
} from "typedoc";
|
|
604
|
+
import path5 from "path";
|
|
605
|
+
import chalk10 from "chalk";
|
|
606
|
+
import { Application, ArgumentsReader, TSConfigReader, TypeDocReader } from "typedoc";
|
|
514
607
|
var ExitCodes = {
|
|
515
608
|
CompileError: 3,
|
|
516
609
|
ExceptionThrown: 6,
|
|
@@ -520,14 +613,17 @@ var ExitCodes = {
|
|
|
520
613
|
OutputError: 5,
|
|
521
614
|
ValidationError: 4
|
|
522
615
|
};
|
|
523
|
-
var packageGenDocs = async () => {
|
|
616
|
+
var packageGenDocs = /* @__PURE__ */ __name(async () => {
|
|
524
617
|
const pkg = process.env.INIT_CWD;
|
|
525
|
-
if (pkg && !existsSync(
|
|
618
|
+
if (pkg !== void 0 && !existsSync(path5.join(pkg, "typedoc.json"))) {
|
|
526
619
|
return;
|
|
527
620
|
}
|
|
528
621
|
const app = await Application.bootstrap({
|
|
529
622
|
entryPointStrategy: "merge",
|
|
530
|
-
entryPoints: [
|
|
623
|
+
entryPoints: [
|
|
624
|
+
`${pkg}/src/**/*.ts`,
|
|
625
|
+
`${pkg}/packages/*/dist/docs.json`
|
|
626
|
+
],
|
|
531
627
|
excludeExternals: true,
|
|
532
628
|
json: `${pkg}/dist/docs.json`,
|
|
533
629
|
logLevel: "Error",
|
|
@@ -538,8 +634,8 @@ var packageGenDocs = async () => {
|
|
|
538
634
|
app.options.addReader(new TSConfigReader());
|
|
539
635
|
app.options.addReader(new ArgumentsReader(300));
|
|
540
636
|
return await runTypeDoc(app);
|
|
541
|
-
};
|
|
542
|
-
var runTypeDoc = async (app) => {
|
|
637
|
+
}, "packageGenDocs");
|
|
638
|
+
var runTypeDoc = /* @__PURE__ */ __name(async (app) => {
|
|
543
639
|
const pkgName = process.env.npm_package_name;
|
|
544
640
|
if (app.options.getValue("version")) {
|
|
545
641
|
console.log(app.toString());
|
|
@@ -608,37 +704,40 @@ var runTypeDoc = async (app) => {
|
|
|
608
704
|
return ExitCodes.OutputError;
|
|
609
705
|
}
|
|
610
706
|
}
|
|
611
|
-
console.log(
|
|
707
|
+
console.log(chalk10.green(`${pkgName} - Ok`));
|
|
612
708
|
return ExitCodes.Ok;
|
|
613
|
-
};
|
|
709
|
+
}, "runTypeDoc");
|
|
614
710
|
|
|
615
711
|
// src/actions/package/lint.ts
|
|
616
712
|
import { readdirSync } from "fs";
|
|
617
|
-
import
|
|
618
|
-
import { cwd as
|
|
713
|
+
import path6 from "path";
|
|
714
|
+
import { cwd as cwd4 } from "process";
|
|
619
715
|
import { pathToFileURL } from "url";
|
|
620
|
-
import
|
|
716
|
+
import chalk11 from "chalk";
|
|
621
717
|
import { ESLint } from "eslint";
|
|
622
718
|
import { findUp } from "find-up";
|
|
623
719
|
import picomatch from "picomatch";
|
|
624
|
-
var dumpMessages = (lintResults) => {
|
|
625
|
-
const colors = [
|
|
626
|
-
|
|
720
|
+
var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
|
|
721
|
+
const colors = [
|
|
722
|
+
"white",
|
|
723
|
+
"yellow",
|
|
724
|
+
"red"
|
|
725
|
+
];
|
|
726
|
+
const severity = [
|
|
727
|
+
"none",
|
|
728
|
+
"warning",
|
|
729
|
+
"error"
|
|
730
|
+
];
|
|
627
731
|
for (const lintResult of lintResults) {
|
|
628
732
|
if (lintResult.messages.length > 0) {
|
|
629
|
-
console.log(
|
|
733
|
+
console.log(chalk11.gray(`
|
|
630
734
|
${lintResult.filePath}`));
|
|
631
735
|
for (const message of lintResult.messages) {
|
|
632
|
-
console.log(
|
|
633
|
-
chalk9.gray(` ${message.line}:${message.column}`),
|
|
634
|
-
chalk9[colors[message.severity]](` ${severity[message.severity]}`),
|
|
635
|
-
chalk9.white(` ${message.message}`),
|
|
636
|
-
chalk9.gray(` ${message.ruleId}`)
|
|
637
|
-
);
|
|
736
|
+
console.log(chalk11.gray(` ${message.line}:${message.column}`), chalk11[colors[message.severity]](` ${severity[message.severity]}`), chalk11.white(` ${message.message}`), chalk11.gray(` ${message.ruleId}`));
|
|
638
737
|
}
|
|
639
738
|
}
|
|
640
739
|
}
|
|
641
|
-
};
|
|
740
|
+
}, "dumpMessages");
|
|
642
741
|
async function getRootESLintConfig() {
|
|
643
742
|
const configPath = await findUp("eslint.config.mjs");
|
|
644
743
|
if (configPath === void 0) {
|
|
@@ -646,33 +745,50 @@ async function getRootESLintConfig() {
|
|
|
646
745
|
}
|
|
647
746
|
return pathToFileURL(configPath);
|
|
648
747
|
}
|
|
748
|
+
__name(getRootESLintConfig, "getRootESLintConfig");
|
|
649
749
|
function getFiles(dir, ignoreFolders) {
|
|
650
|
-
const currentDirectory =
|
|
750
|
+
const currentDirectory = cwd4();
|
|
651
751
|
const subDirectory = dir.split(currentDirectory)[1];
|
|
652
752
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
653
|
-
return readdirSync(dir, {
|
|
654
|
-
|
|
753
|
+
return readdirSync(dir, {
|
|
754
|
+
withFileTypes: true
|
|
755
|
+
}).flatMap((dirent) => {
|
|
756
|
+
const res = path6.resolve(dir, dirent.name);
|
|
655
757
|
const relativePath = subDirectory === void 0 ? dirent.name : `${subDirectory}/${dirent.name}`;
|
|
656
758
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
657
759
|
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
658
|
-
return dirent.isDirectory() ? getFiles(res, ignoreFolders) : [
|
|
760
|
+
return dirent.isDirectory() ? getFiles(res, ignoreFolders) : [
|
|
761
|
+
res
|
|
762
|
+
];
|
|
659
763
|
});
|
|
660
764
|
}
|
|
661
|
-
|
|
765
|
+
__name(getFiles, "getFiles");
|
|
766
|
+
var packageLint = /* @__PURE__ */ __name(async (fix = false, verbose = false, cache = true) => {
|
|
662
767
|
const pkg = process.env.INIT_CWD;
|
|
663
768
|
const configPath = await getRootESLintConfig();
|
|
664
769
|
const { default: eslintConfig } = await import(configPath.href);
|
|
665
770
|
const start = Date.now();
|
|
666
|
-
const ignoreFolders = [
|
|
771
|
+
const ignoreFolders = [
|
|
772
|
+
"node_modules",
|
|
773
|
+
"dist",
|
|
774
|
+
"packages",
|
|
775
|
+
".git",
|
|
776
|
+
"build",
|
|
777
|
+
".yarn",
|
|
778
|
+
".vscode",
|
|
779
|
+
".github"
|
|
780
|
+
];
|
|
667
781
|
const engine = new ESLint({
|
|
668
|
-
baseConfig: [
|
|
782
|
+
baseConfig: [
|
|
783
|
+
...eslintConfig
|
|
784
|
+
],
|
|
669
785
|
fix,
|
|
670
786
|
warnIgnored: false,
|
|
671
787
|
cache
|
|
672
788
|
});
|
|
673
|
-
const files = getFiles(
|
|
789
|
+
const files = getFiles(cwd4(), ignoreFolders);
|
|
674
790
|
if (verbose) {
|
|
675
|
-
console.log(
|
|
791
|
+
console.log(chalk11.green(`Linting ${pkg} [files = ${files.length}]`));
|
|
676
792
|
}
|
|
677
793
|
const lintResults = await engine.lintFiles(files);
|
|
678
794
|
dumpMessages(lintResults);
|
|
@@ -682,14 +798,58 @@ var packageLint = async (fix = false, verbose = false, cache = true) => {
|
|
|
682
798
|
const filesCountColor = files.length < 100 ? "green" : files.length < 1e3 ? "yellow" : "red";
|
|
683
799
|
const lintTime = Date.now() - start;
|
|
684
800
|
const lintTimeColor = lintTime < 1e3 ? "green" : lintTime < 3e3 ? "yellow" : "red";
|
|
685
|
-
console.log(
|
|
801
|
+
console.log(chalk11.white(`Linted ${chalk11[filesCountColor](files.length)} files in ${chalk11[lintTimeColor](lintTime)}ms`));
|
|
686
802
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
687
|
-
};
|
|
803
|
+
}, "packageLint");
|
|
804
|
+
|
|
805
|
+
// src/actions/package/publint.ts
|
|
806
|
+
import { promises as fs2 } from "fs";
|
|
807
|
+
import chalk12 from "chalk";
|
|
808
|
+
import sortPackageJson from "sort-package-json";
|
|
809
|
+
var packagePublint = /* @__PURE__ */ __name(async ({ strict = true, verbose = false } = {}) => {
|
|
810
|
+
const pkgDir = process.env.INIT_CWD;
|
|
811
|
+
const sortedPkg = sortPackageJson(await fs2.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
812
|
+
await fs2.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
813
|
+
const pkg = JSON.parse(await fs2.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
814
|
+
console.log(chalk12.green(`Publint: ${pkg.name}`));
|
|
815
|
+
console.log(chalk12.gray(pkgDir));
|
|
816
|
+
const { publint } = await import("publint");
|
|
817
|
+
const { messages } = await publint({
|
|
818
|
+
level: "suggestion",
|
|
819
|
+
pkgDir,
|
|
820
|
+
strict
|
|
821
|
+
});
|
|
822
|
+
const { formatMessage } = await import("publint/utils");
|
|
823
|
+
const validMessage = /* @__PURE__ */ __name((_message) => {
|
|
824
|
+
return true;
|
|
825
|
+
}, "validMessage");
|
|
826
|
+
const validMessages = messages.filter(validMessage);
|
|
827
|
+
for (const message of validMessages) {
|
|
828
|
+
switch (message.type) {
|
|
829
|
+
case "error": {
|
|
830
|
+
console.error(chalk12.red(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
831
|
+
break;
|
|
832
|
+
}
|
|
833
|
+
case "warning": {
|
|
834
|
+
console.warn(chalk12.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
835
|
+
break;
|
|
836
|
+
}
|
|
837
|
+
default: {
|
|
838
|
+
console.log(chalk12.white(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
839
|
+
break;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
if (verbose) {
|
|
844
|
+
console.log(chalk12.gray(`Publint [Finish]: ${pkgDir} [${validMessages.length}]`));
|
|
845
|
+
}
|
|
846
|
+
return validMessages.filter((message) => message.type === "error").length;
|
|
847
|
+
}, "packagePublint");
|
|
688
848
|
|
|
689
849
|
// src/actions/package/recompile.ts
|
|
690
|
-
var packageRecompile = async () => {
|
|
850
|
+
var packageRecompile = /* @__PURE__ */ __name(async () => {
|
|
691
851
|
return await packageClean() || await packageCompile();
|
|
692
|
-
};
|
|
852
|
+
}, "packageRecompile");
|
|
693
853
|
export {
|
|
694
854
|
bundleDts,
|
|
695
855
|
packageClean,
|