@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,9 +1,12 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
1
4
|
// src/xy/xyLintCommands.ts
|
|
2
5
|
import chalk12 from "chalk";
|
|
3
6
|
|
|
4
7
|
// src/lib/checkResult.ts
|
|
5
8
|
import chalk from "chalk";
|
|
6
|
-
var checkResult = (name, result, level = "error", exitOnFail = false) => {
|
|
9
|
+
var checkResult = /* @__PURE__ */ __name((name, result, level = "error", exitOnFail = false) => {
|
|
7
10
|
if (result) {
|
|
8
11
|
const exiting = exitOnFail ? "[Exiting Process]" : "[Continuing]";
|
|
9
12
|
const chalkFunc = level === "error" ? chalk.red : chalk.yellow;
|
|
@@ -12,23 +15,23 @@ var checkResult = (name, result, level = "error", exitOnFail = false) => {
|
|
|
12
15
|
process.exit(result);
|
|
13
16
|
}
|
|
14
17
|
}
|
|
15
|
-
};
|
|
18
|
+
}, "checkResult");
|
|
16
19
|
|
|
17
20
|
// src/lib/processEx.ts
|
|
18
21
|
import chalk2 from "chalk";
|
|
19
22
|
|
|
20
23
|
// src/lib/withError.ts
|
|
21
|
-
var withError = (ex, closure, predicate = (ex2) => !!ex2.name && !!ex2.message) => {
|
|
24
|
+
var withError = /* @__PURE__ */ __name((ex, closure, predicate = (ex2) => !!ex2.name && !!ex2.message) => {
|
|
22
25
|
return predicate(ex) ? closure(ex) : void 0;
|
|
23
|
-
};
|
|
26
|
+
}, "withError");
|
|
24
27
|
|
|
25
28
|
// src/lib/withErrnoException.ts
|
|
26
|
-
var withErrnoException = (ex, closure) => {
|
|
29
|
+
var withErrnoException = /* @__PURE__ */ __name((ex, closure) => {
|
|
27
30
|
return withError(ex, closure, (ex2) => ex2.errno !== void 0);
|
|
28
|
-
};
|
|
31
|
+
}, "withErrnoException");
|
|
29
32
|
|
|
30
33
|
// src/lib/processEx.ts
|
|
31
|
-
var processEx = (ex) => {
|
|
34
|
+
var processEx = /* @__PURE__ */ __name((ex) => {
|
|
32
35
|
const error = typeof ex === "string" ? new Error(ex) : ex;
|
|
33
36
|
const exitCode = withErrnoException(error, (error2) => {
|
|
34
37
|
if (error2.code === "ENOENT") {
|
|
@@ -45,10 +48,10 @@ var processEx = (ex) => {
|
|
|
45
48
|
return -1;
|
|
46
49
|
})();
|
|
47
50
|
process.exit(process.exitCode ?? exitCode);
|
|
48
|
-
};
|
|
51
|
+
}, "processEx");
|
|
49
52
|
|
|
50
53
|
// src/lib/safeExit.ts
|
|
51
|
-
var safeExit = (func, exitOnFail = true) => {
|
|
54
|
+
var safeExit = /* @__PURE__ */ __name((func, exitOnFail = true) => {
|
|
52
55
|
try {
|
|
53
56
|
const result = func();
|
|
54
57
|
if (result && exitOnFail) {
|
|
@@ -58,8 +61,8 @@ var safeExit = (func, exitOnFail = true) => {
|
|
|
58
61
|
} catch (ex) {
|
|
59
62
|
return processEx(ex);
|
|
60
63
|
}
|
|
61
|
-
};
|
|
62
|
-
var safeExitAsync = async (func, exitOnFail = true) => {
|
|
64
|
+
}, "safeExit");
|
|
65
|
+
var safeExitAsync = /* @__PURE__ */ __name(async (func, exitOnFail = true) => {
|
|
63
66
|
try {
|
|
64
67
|
const result = await func();
|
|
65
68
|
if (result && exitOnFail) {
|
|
@@ -69,32 +72,40 @@ var safeExitAsync = async (func, exitOnFail = true) => {
|
|
|
69
72
|
} catch (ex) {
|
|
70
73
|
return processEx(ex);
|
|
71
74
|
}
|
|
72
|
-
};
|
|
75
|
+
}, "safeExitAsync");
|
|
73
76
|
|
|
74
77
|
// src/lib/yarn/workspace/yarnWorkspaces.ts
|
|
75
78
|
import { spawnSync } from "child_process";
|
|
76
|
-
var yarnWorkspaces = () => {
|
|
77
|
-
const result = spawnSync("yarn", [
|
|
79
|
+
var yarnWorkspaces = /* @__PURE__ */ __name(() => {
|
|
80
|
+
const result = spawnSync("yarn", [
|
|
81
|
+
"workspaces",
|
|
82
|
+
"list",
|
|
83
|
+
"--json",
|
|
84
|
+
"--recursive"
|
|
85
|
+
], {
|
|
86
|
+
encoding: "utf8",
|
|
87
|
+
shell: true
|
|
88
|
+
});
|
|
78
89
|
if (result.error) {
|
|
79
90
|
throw result.error;
|
|
80
91
|
}
|
|
81
92
|
return result.stdout.toString().split("\n").slice(0, -1).map((item) => {
|
|
82
93
|
return JSON.parse(item);
|
|
83
94
|
});
|
|
84
|
-
};
|
|
95
|
+
}, "yarnWorkspaces");
|
|
85
96
|
|
|
86
97
|
// src/lib/yarn/workspace/yarnWorkspace.ts
|
|
87
|
-
var yarnWorkspace = (pkg) => {
|
|
98
|
+
var yarnWorkspace = /* @__PURE__ */ __name((pkg) => {
|
|
88
99
|
const workspace = yarnWorkspaces().find(({ name }) => name === pkg);
|
|
89
100
|
if (!workspace) throw new Error(`Workspace ${pkg} not found`);
|
|
90
101
|
return workspace;
|
|
91
|
-
};
|
|
102
|
+
}, "yarnWorkspace");
|
|
92
103
|
|
|
93
104
|
// src/lib/runSteps.ts
|
|
94
105
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
95
106
|
import { existsSync } from "fs";
|
|
96
107
|
import chalk3 from "chalk";
|
|
97
|
-
var runSteps = (name, steps, exitOnFail = true, messages) => {
|
|
108
|
+
var runSteps = /* @__PURE__ */ __name((name, steps, exitOnFail = true, messages) => {
|
|
98
109
|
return safeExit(() => {
|
|
99
110
|
const pkgName = process.env.npm_package_name;
|
|
100
111
|
console.log(chalk3.green(`${name} [${pkgName}]`));
|
|
@@ -110,7 +121,10 @@ var runSteps = (name, steps, exitOnFail = true, messages) => {
|
|
|
110
121
|
const status = spawnSync2(command, Array.isArray(args) ? args : args.split(" "), {
|
|
111
122
|
...config,
|
|
112
123
|
encoding: "utf8",
|
|
113
|
-
env: {
|
|
124
|
+
env: {
|
|
125
|
+
FORCE_COLOR: "3",
|
|
126
|
+
...process.env
|
|
127
|
+
},
|
|
114
128
|
shell: true,
|
|
115
129
|
stdio: "inherit"
|
|
116
130
|
}).status ?? 0;
|
|
@@ -119,13 +133,13 @@ var runSteps = (name, steps, exitOnFail = true, messages) => {
|
|
|
119
133
|
}
|
|
120
134
|
return totalStatus;
|
|
121
135
|
}, !!exitOnFail);
|
|
122
|
-
};
|
|
136
|
+
}, "runSteps");
|
|
123
137
|
|
|
124
138
|
// src/lib/runStepsAsync.ts
|
|
125
139
|
import { spawn } from "child_process";
|
|
126
140
|
import { existsSync as existsSync2 } from "fs";
|
|
127
141
|
import chalk4 from "chalk";
|
|
128
|
-
var runStepAsync = (name, step, exitOnFail = true, message) => {
|
|
142
|
+
var runStepAsync = /* @__PURE__ */ __name((name, step, exitOnFail = true, message) => {
|
|
129
143
|
return new Promise((resolve) => {
|
|
130
144
|
const [command, args, config] = step;
|
|
131
145
|
if (message) {
|
|
@@ -137,18 +151,15 @@ var runStepAsync = (name, step, exitOnFail = true, message) => {
|
|
|
137
151
|
}
|
|
138
152
|
spawn(command, Array.isArray(args) ? args : args.split(" "), {
|
|
139
153
|
...config,
|
|
140
|
-
env: {
|
|
154
|
+
env: {
|
|
155
|
+
FORCE_COLOR: "3",
|
|
156
|
+
...process.env
|
|
157
|
+
},
|
|
141
158
|
shell: true,
|
|
142
159
|
stdio: "inherit"
|
|
143
160
|
}).on("close", (code) => {
|
|
144
161
|
if (code) {
|
|
145
|
-
console.error(
|
|
146
|
-
chalk4.red(
|
|
147
|
-
`Command Exited With Non-Zero Result [${chalk4.gray(code)}] | ${chalk4.yellow(command)} ${chalk4.white(
|
|
148
|
-
Array.isArray(args) ? args.join(" ") : args
|
|
149
|
-
)}`
|
|
150
|
-
)
|
|
151
|
-
);
|
|
162
|
+
console.error(chalk4.red(`Command Exited With Non-Zero Result [${chalk4.gray(code)}] | ${chalk4.yellow(command)} ${chalk4.white(Array.isArray(args) ? args.join(" ") : args)}`));
|
|
152
163
|
checkResult(name, code, "error", exitOnFail);
|
|
153
164
|
resolve(code);
|
|
154
165
|
} else {
|
|
@@ -156,8 +167,8 @@ var runStepAsync = (name, step, exitOnFail = true, message) => {
|
|
|
156
167
|
}
|
|
157
168
|
});
|
|
158
169
|
});
|
|
159
|
-
};
|
|
160
|
-
var runStepsAsync = async (name, steps, exitOnFail = true, messages) => {
|
|
170
|
+
}, "runStepAsync");
|
|
171
|
+
var runStepsAsync = /* @__PURE__ */ __name(async (name, steps, exitOnFail = true, messages) => {
|
|
161
172
|
return await safeExitAsync(async () => {
|
|
162
173
|
const pkgName = process.env.npm_package_name;
|
|
163
174
|
console.log(chalk4.green(`${name} [${pkgName}]`));
|
|
@@ -167,21 +178,38 @@ var runStepsAsync = async (name, steps, exitOnFail = true, messages) => {
|
|
|
167
178
|
}
|
|
168
179
|
return result;
|
|
169
180
|
});
|
|
170
|
-
};
|
|
181
|
+
}, "runStepsAsync");
|
|
171
182
|
|
|
172
183
|
// src/actions/cycle.ts
|
|
173
184
|
import { cruise } from "dependency-cruiser";
|
|
174
|
-
var cycle = async ({ verbose, pkg } = {}) => {
|
|
175
|
-
return pkg ? cyclePackage({
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
+
var cycle = /* @__PURE__ */ __name(async ({ verbose, pkg } = {}) => {
|
|
186
|
+
return pkg ? cyclePackage({
|
|
187
|
+
pkg,
|
|
188
|
+
verbose
|
|
189
|
+
}) : await cycleAll({
|
|
190
|
+
verbose
|
|
191
|
+
});
|
|
192
|
+
}, "cycle");
|
|
193
|
+
var cyclePackage = /* @__PURE__ */ __name(({ pkg, verbose }) => {
|
|
194
|
+
const verboseOptions = verbose ? [
|
|
195
|
+
"--verbose"
|
|
196
|
+
] : [
|
|
197
|
+
"--no-verbose"
|
|
198
|
+
];
|
|
199
|
+
return runSteps(`Cycle [${pkg}]`, [
|
|
200
|
+
[
|
|
201
|
+
"yarn",
|
|
202
|
+
[
|
|
203
|
+
"workspace",
|
|
204
|
+
pkg,
|
|
205
|
+
"run",
|
|
206
|
+
"package-cycle",
|
|
207
|
+
...verboseOptions
|
|
208
|
+
]
|
|
209
|
+
]
|
|
210
|
+
]);
|
|
211
|
+
}, "cyclePackage");
|
|
212
|
+
var cycleAll = /* @__PURE__ */ __name(async ({ verbose = false }) => {
|
|
185
213
|
const pkgName = process.env.npm_package_name;
|
|
186
214
|
const cruiseOptions = {
|
|
187
215
|
ruleSet: {
|
|
@@ -191,20 +219,26 @@ var cycleAll = async ({ verbose = false }) => {
|
|
|
191
219
|
severity: "error",
|
|
192
220
|
comment: "This dependency creates a circular reference",
|
|
193
221
|
from: {},
|
|
194
|
-
to: {
|
|
222
|
+
to: {
|
|
223
|
+
circular: true
|
|
224
|
+
}
|
|
195
225
|
}
|
|
196
226
|
]
|
|
197
227
|
},
|
|
198
228
|
exclude: "node_modules|packages/.*/packages",
|
|
199
229
|
validate: true,
|
|
200
|
-
doNotFollow: {
|
|
230
|
+
doNotFollow: {
|
|
231
|
+
path: "node_modules|packages/.*/packages"
|
|
232
|
+
},
|
|
201
233
|
tsPreCompilationDeps: false,
|
|
202
234
|
combinedDependencies: true,
|
|
203
235
|
outputType: verbose ? "text" : "err"
|
|
204
236
|
};
|
|
205
237
|
const target = "**/src";
|
|
206
238
|
console.log(`Checking for circular dependencies in ${target}...`);
|
|
207
|
-
const result = await cruise([
|
|
239
|
+
const result = await cruise([
|
|
240
|
+
target
|
|
241
|
+
], cruiseOptions);
|
|
208
242
|
if (result.output) {
|
|
209
243
|
console.log(result.output);
|
|
210
244
|
}
|
|
@@ -214,7 +248,7 @@ var cycleAll = async ({ verbose = false }) => {
|
|
|
214
248
|
console.error(`${pkgName} \u274C Dependency violations found`);
|
|
215
249
|
}
|
|
216
250
|
return result.exitCode;
|
|
217
|
-
};
|
|
251
|
+
}, "cycleAll");
|
|
218
252
|
|
|
219
253
|
// src/actions/deplint/deplint.ts
|
|
220
254
|
import chalk9 from "chalk";
|
|
@@ -222,17 +256,30 @@ import chalk9 from "chalk";
|
|
|
222
256
|
// src/actions/deplint/findFilesByGlob.ts
|
|
223
257
|
import { globSync } from "glob";
|
|
224
258
|
function findFilesByGlob(cwd, pattern) {
|
|
225
|
-
return globSync(pattern, {
|
|
259
|
+
return globSync(pattern, {
|
|
260
|
+
cwd,
|
|
261
|
+
absolute: true
|
|
262
|
+
});
|
|
226
263
|
}
|
|
264
|
+
__name(findFilesByGlob, "findFilesByGlob");
|
|
227
265
|
|
|
228
266
|
// src/actions/deplint/findFiles.ts
|
|
229
267
|
function findFiles(path3) {
|
|
230
|
-
const allSourceInclude = [
|
|
231
|
-
|
|
268
|
+
const allSourceInclude = [
|
|
269
|
+
"./src/**/*.{ts,tsx}"
|
|
270
|
+
];
|
|
271
|
+
const allDistInclude = [
|
|
272
|
+
"./dist/**/*.d.ts",
|
|
273
|
+
"./dist/**/*.{mjs,js,cjs}"
|
|
274
|
+
];
|
|
232
275
|
const srcFiles = allSourceInclude.flatMap((pattern) => findFilesByGlob(path3, pattern));
|
|
233
276
|
const distFiles = allDistInclude.flatMap((pattern) => findFilesByGlob(path3, pattern));
|
|
234
|
-
return {
|
|
277
|
+
return {
|
|
278
|
+
srcFiles,
|
|
279
|
+
distFiles
|
|
280
|
+
};
|
|
235
281
|
}
|
|
282
|
+
__name(findFiles, "findFiles");
|
|
236
283
|
|
|
237
284
|
// src/actions/deplint/getDependenciesFromPackageJson.ts
|
|
238
285
|
import fs from "fs";
|
|
@@ -250,6 +297,7 @@ function getDependenciesFromPackageJson(packageJsonPath) {
|
|
|
250
297
|
peerDependencies
|
|
251
298
|
};
|
|
252
299
|
}
|
|
300
|
+
__name(getDependenciesFromPackageJson, "getDependenciesFromPackageJson");
|
|
253
301
|
|
|
254
302
|
// src/actions/deplint/getImportsFromFile.ts
|
|
255
303
|
import fs2 from "fs";
|
|
@@ -265,18 +313,13 @@ function getBasePackageName(importName) {
|
|
|
265
313
|
}
|
|
266
314
|
return importNameScrubbed.split("/")[0];
|
|
267
315
|
}
|
|
316
|
+
__name(getBasePackageName, "getBasePackageName");
|
|
268
317
|
|
|
269
318
|
// src/actions/deplint/getImportsFromFile.ts
|
|
270
319
|
function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
271
320
|
const sourceCode = fs2.readFileSync(filePath, "utf8");
|
|
272
321
|
const isMjsFile = filePath.endsWith(".mjs");
|
|
273
|
-
const sourceFile = ts.createSourceFile(
|
|
274
|
-
path2.basename(filePath),
|
|
275
|
-
sourceCode,
|
|
276
|
-
ts.ScriptTarget.Latest,
|
|
277
|
-
true,
|
|
278
|
-
isMjsFile ? ts.ScriptKind.JS : void 0
|
|
279
|
-
);
|
|
322
|
+
const sourceFile = ts.createSourceFile(path2.basename(filePath), sourceCode, ts.ScriptTarget.Latest, true, isMjsFile ? ts.ScriptKind.JS : void 0);
|
|
280
323
|
const imports = [];
|
|
281
324
|
const typeImports = [];
|
|
282
325
|
const isDeclarationFile = filePath.endsWith(".d.ts");
|
|
@@ -301,8 +344,13 @@ function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
|
301
344
|
}
|
|
302
345
|
ts.forEachChild(node, visit);
|
|
303
346
|
}
|
|
347
|
+
__name(visit, "visit");
|
|
304
348
|
visit(sourceFile);
|
|
305
|
-
const importsStartsWithExcludes = [
|
|
349
|
+
const importsStartsWithExcludes = [
|
|
350
|
+
".",
|
|
351
|
+
"#",
|
|
352
|
+
"node:"
|
|
353
|
+
];
|
|
306
354
|
const cleanedImports = imports.filter((imp) => !importsStartsWithExcludes.some((exc) => imp.startsWith(exc))).map(getBasePackageName);
|
|
307
355
|
const cleanedTypeImports = typeImports.filter((imp) => !importsStartsWithExcludes.some((exc) => imp.startsWith(exc))).map(getBasePackageName);
|
|
308
356
|
for (const imp of cleanedImports) {
|
|
@@ -313,14 +361,22 @@ function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
|
313
361
|
typeImportPaths[imp] = typeImportPaths[imp] ?? [];
|
|
314
362
|
typeImportPaths[imp].push(filePath);
|
|
315
363
|
}
|
|
316
|
-
return [
|
|
364
|
+
return [
|
|
365
|
+
cleanedImports,
|
|
366
|
+
cleanedTypeImports
|
|
367
|
+
];
|
|
317
368
|
}
|
|
369
|
+
__name(getImportsFromFile, "getImportsFromFile");
|
|
318
370
|
|
|
319
371
|
// src/actions/deplint/getExternalImportsFromFiles.ts
|
|
320
|
-
var internalImportPrefixes = [
|
|
321
|
-
|
|
372
|
+
var internalImportPrefixes = [
|
|
373
|
+
".",
|
|
374
|
+
"#",
|
|
375
|
+
"node:"
|
|
376
|
+
];
|
|
377
|
+
var removeInternalImports = /* @__PURE__ */ __name((imports) => {
|
|
322
378
|
return imports.filter((imp) => !internalImportPrefixes.some((prefix) => imp.startsWith(prefix)));
|
|
323
|
-
};
|
|
379
|
+
}, "removeInternalImports");
|
|
324
380
|
function getExternalImportsFromFiles({ srcFiles, distFiles }) {
|
|
325
381
|
const srcImportPaths = {};
|
|
326
382
|
const distImportPaths = {};
|
|
@@ -346,25 +402,22 @@ function getExternalImportsFromFiles({ srcFiles, distFiles }) {
|
|
|
346
402
|
externalDistTypeImports
|
|
347
403
|
};
|
|
348
404
|
}
|
|
405
|
+
__name(getExternalImportsFromFiles, "getExternalImportsFromFiles");
|
|
349
406
|
|
|
350
407
|
// src/actions/deplint/checkPackage/getUnlistedDependencies.ts
|
|
351
408
|
import { builtinModules } from "module";
|
|
352
409
|
import chalk5 from "chalk";
|
|
353
|
-
function getUnlistedDependencies({ name, location }, { dependencies, peerDependencies }, {
|
|
354
|
-
externalDistImports,
|
|
355
|
-
externalDistTypeImports,
|
|
356
|
-
distImportPaths
|
|
357
|
-
}) {
|
|
410
|
+
function getUnlistedDependencies({ name, location }, { dependencies, peerDependencies }, { externalDistImports, externalDistTypeImports, distImportPaths }) {
|
|
358
411
|
let unlistedDependencies = 0;
|
|
359
412
|
for (const imp of externalDistImports) {
|
|
360
|
-
if (!dependencies.includes(imp) && !dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && !peerDependencies.includes(`@types/${imp}`) && !builtinModules.includes(imp) && !builtinModules.includes(`@types/${imp}`)) {
|
|
413
|
+
if (!dependencies.includes(imp) && imp !== name && !dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && !peerDependencies.includes(`@types/${imp}`) && !builtinModules.includes(imp) && !builtinModules.includes(`@types/${imp}`)) {
|
|
361
414
|
unlistedDependencies++;
|
|
362
415
|
console.log(`[${chalk5.blue(name)}] Missing dependency in package.json: ${chalk5.red(imp)}`);
|
|
363
416
|
console.log(` ${distImportPaths[imp].join("\n ")}`);
|
|
364
417
|
}
|
|
365
418
|
}
|
|
366
419
|
for (const imp of externalDistTypeImports) {
|
|
367
|
-
if (!dependencies.includes(imp) && dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && peerDependencies.includes(`@types/${imp}`) && !builtinModules.includes(imp) && builtinModules.includes(`@types/${imp}`)) {
|
|
420
|
+
if (!dependencies.includes(imp) && imp !== name && dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && peerDependencies.includes(`@types/${imp}`) && !builtinModules.includes(imp) && builtinModules.includes(`@types/${imp}`)) {
|
|
368
421
|
unlistedDependencies++;
|
|
369
422
|
console.log(`[${chalk5.blue(name)}] Missing dependency in package.json: ${chalk5.red(imp)}`);
|
|
370
423
|
console.log(` ${distImportPaths[imp].join("\n ")}`);
|
|
@@ -377,22 +430,15 @@ function getUnlistedDependencies({ name, location }, { dependencies, peerDepende
|
|
|
377
430
|
}
|
|
378
431
|
return unlistedDependencies;
|
|
379
432
|
}
|
|
433
|
+
__name(getUnlistedDependencies, "getUnlistedDependencies");
|
|
380
434
|
|
|
381
435
|
// src/actions/deplint/checkPackage/getUnlistedDevDependencies.ts
|
|
382
436
|
import { builtinModules as builtinModules2 } from "module";
|
|
383
437
|
import chalk6 from "chalk";
|
|
384
|
-
function getUnlistedDevDependencies({ name, location }, {
|
|
385
|
-
devDependencies,
|
|
386
|
-
dependencies,
|
|
387
|
-
peerDependencies
|
|
388
|
-
}, {
|
|
389
|
-
srcImportPaths,
|
|
390
|
-
externalSrcImports,
|
|
391
|
-
distImports
|
|
392
|
-
}) {
|
|
438
|
+
function getUnlistedDevDependencies({ name, location }, { devDependencies, dependencies, peerDependencies }, { srcImportPaths, externalSrcImports, distImports }) {
|
|
393
439
|
let unlistedDevDependencies = 0;
|
|
394
440
|
for (const imp of externalSrcImports) {
|
|
395
|
-
if (!distImports.includes(imp) && !dependencies.includes(imp) && !dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && !peerDependencies.includes(`@types/${imp}`) && !devDependencies.includes(imp) && !devDependencies.includes(`@types/${imp}`) && !builtinModules2.includes(imp)) {
|
|
441
|
+
if (!distImports.includes(imp) && imp !== name && !dependencies.includes(imp) && !dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && !peerDependencies.includes(`@types/${imp}`) && !devDependencies.includes(imp) && !devDependencies.includes(`@types/${imp}`) && !builtinModules2.includes(imp)) {
|
|
396
442
|
unlistedDevDependencies++;
|
|
397
443
|
console.log(`[${chalk6.blue(name)}] Missing devDependency in package.json: ${chalk6.red(imp)}`);
|
|
398
444
|
console.log(` ${srcImportPaths[imp].join("\n ")}`);
|
|
@@ -405,14 +451,11 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
405
451
|
}
|
|
406
452
|
return unlistedDevDependencies;
|
|
407
453
|
}
|
|
454
|
+
__name(getUnlistedDevDependencies, "getUnlistedDevDependencies");
|
|
408
455
|
|
|
409
456
|
// src/actions/deplint/checkPackage/getUnusedDependencies.ts
|
|
410
457
|
import chalk7 from "chalk";
|
|
411
|
-
function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
412
|
-
externalDistImports,
|
|
413
|
-
externalDistTypeImports,
|
|
414
|
-
externalSrcImports
|
|
415
|
-
}) {
|
|
458
|
+
function getUnusedDependencies({ name, location }, { dependencies }, { externalDistImports, externalDistTypeImports, externalSrcImports }) {
|
|
416
459
|
let unusedDependencies = 0;
|
|
417
460
|
for (const dep of dependencies) {
|
|
418
461
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
@@ -431,6 +474,7 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
|
431
474
|
}
|
|
432
475
|
return unusedDependencies;
|
|
433
476
|
}
|
|
477
|
+
__name(getUnusedDependencies, "getUnusedDependencies");
|
|
434
478
|
|
|
435
479
|
// src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
|
|
436
480
|
import chalk8 from "chalk";
|
|
@@ -453,310 +497,382 @@ function getUnusedPeerDependencies({ name, location }, { peerDependencies, depen
|
|
|
453
497
|
}
|
|
454
498
|
return unusedDependencies;
|
|
455
499
|
}
|
|
500
|
+
__name(getUnusedPeerDependencies, "getUnusedPeerDependencies");
|
|
456
501
|
|
|
457
502
|
// src/actions/deplint/checkPackage/checkPackage.ts
|
|
458
|
-
function checkPackage({
|
|
459
|
-
name,
|
|
460
|
-
location,
|
|
461
|
-
deps = false,
|
|
462
|
-
devDeps = false,
|
|
463
|
-
peerDeps = false
|
|
464
|
-
}) {
|
|
503
|
+
function checkPackage({ name, location, deps = false, devDeps = false, peerDeps = false, verbose = false }) {
|
|
465
504
|
const { srcFiles, distFiles } = findFiles(location);
|
|
505
|
+
if (verbose) {
|
|
506
|
+
console.info(`Checking package: ${name} at ${location}`);
|
|
507
|
+
console.info(`Source files: ${srcFiles.length}, Distribution files: ${distFiles.length}`);
|
|
508
|
+
for (const file of srcFiles) {
|
|
509
|
+
console.info(`Source file: ${file}`);
|
|
510
|
+
}
|
|
511
|
+
for (const file of distFiles) {
|
|
512
|
+
console.info(`Distribution file: ${file}`);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
466
515
|
const checkDeps = deps || !(deps || devDeps || peerDeps);
|
|
467
516
|
const checkDevDeps = devDeps || !(deps || devDeps || peerDeps);
|
|
468
517
|
const checkPeerDeps = peerDeps;
|
|
469
|
-
const sourceParams = getExternalImportsFromFiles({
|
|
518
|
+
const sourceParams = getExternalImportsFromFiles({
|
|
519
|
+
srcFiles,
|
|
520
|
+
distFiles
|
|
521
|
+
});
|
|
470
522
|
const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
471
|
-
const unlistedDependencies = checkDeps ? getUnlistedDependencies({
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
523
|
+
const unlistedDependencies = checkDeps ? getUnlistedDependencies({
|
|
524
|
+
name,
|
|
525
|
+
location
|
|
526
|
+
}, packageParams, sourceParams) : 0;
|
|
527
|
+
const unusedDependencies = checkDeps ? getUnusedDependencies({
|
|
528
|
+
name,
|
|
529
|
+
location
|
|
530
|
+
}, packageParams, sourceParams) : 0;
|
|
531
|
+
const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({
|
|
532
|
+
name,
|
|
533
|
+
location
|
|
534
|
+
}, packageParams, sourceParams) : 0;
|
|
535
|
+
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({
|
|
536
|
+
name,
|
|
537
|
+
location
|
|
538
|
+
}, packageParams, sourceParams) : 0;
|
|
475
539
|
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedPeerDependencies;
|
|
476
540
|
return totalErrors;
|
|
477
541
|
}
|
|
542
|
+
__name(checkPackage, "checkPackage");
|
|
478
543
|
|
|
479
544
|
// src/actions/deplint/deplint.ts
|
|
480
|
-
var deplint = ({
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
devDeps,
|
|
484
|
-
peerDeps
|
|
485
|
-
}) => {
|
|
486
|
-
if (pkg) {
|
|
487
|
-
const { location, name } = yarnWorkspace(pkg);
|
|
488
|
-
console.log(`Running Deplint for ${name}`);
|
|
489
|
-
checkPackage({
|
|
490
|
-
name,
|
|
491
|
-
location,
|
|
492
|
-
devDeps,
|
|
493
|
-
deps,
|
|
494
|
-
peerDeps
|
|
495
|
-
});
|
|
496
|
-
} else {
|
|
545
|
+
var deplint = /* @__PURE__ */ __name(({ pkg, deps, devDeps, peerDeps, verbose }) => {
|
|
546
|
+
let totalErrors = 0;
|
|
547
|
+
if (pkg === void 0) {
|
|
497
548
|
const workspaces = yarnWorkspaces();
|
|
498
|
-
console.
|
|
499
|
-
let totalErrors = 0;
|
|
549
|
+
console.info("Deplint Started...");
|
|
500
550
|
for (const workspace of workspaces) {
|
|
501
551
|
totalErrors += checkPackage({
|
|
502
552
|
...workspace,
|
|
503
553
|
deps,
|
|
504
554
|
devDeps,
|
|
505
|
-
peerDeps
|
|
555
|
+
peerDeps,
|
|
556
|
+
verbose
|
|
506
557
|
});
|
|
507
558
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
559
|
+
} else {
|
|
560
|
+
const { location, name } = yarnWorkspace(pkg);
|
|
561
|
+
console.info(`Running Deplint for ${name}`);
|
|
562
|
+
totalErrors += checkPackage({
|
|
563
|
+
name,
|
|
564
|
+
location,
|
|
565
|
+
devDeps,
|
|
566
|
+
deps,
|
|
567
|
+
peerDeps,
|
|
568
|
+
verbose
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
if (totalErrors > 0) {
|
|
572
|
+
console.warn(`Deplint: Found ${chalk9.red(totalErrors)} dependency problems. ${chalk9.red("\u2716")}`);
|
|
573
|
+
} else {
|
|
574
|
+
console.info(`Deplint: Found no dependency problems. ${chalk9.green("\u2714")}`);
|
|
513
575
|
}
|
|
514
576
|
return 0;
|
|
515
|
-
};
|
|
577
|
+
}, "deplint");
|
|
516
578
|
|
|
517
579
|
// src/actions/lint.ts
|
|
518
580
|
import chalk10 from "chalk";
|
|
519
|
-
var lintPackage = ({ pkg, fix: fix2 }) => {
|
|
581
|
+
var lintPackage = /* @__PURE__ */ __name(({ pkg, fix: fix2 }) => {
|
|
520
582
|
console.log(chalk10.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
521
583
|
const start = Date.now();
|
|
522
584
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
523
|
-
[
|
|
524
|
-
"
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
585
|
+
[
|
|
586
|
+
"yarn",
|
|
587
|
+
[
|
|
588
|
+
"workspace",
|
|
589
|
+
pkg,
|
|
590
|
+
"run",
|
|
591
|
+
fix2 ? "package-fix" : "package-lint"
|
|
592
|
+
]
|
|
593
|
+
]
|
|
529
594
|
]);
|
|
530
595
|
console.log(chalk10.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk10.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk10.gray("seconds")}`));
|
|
531
596
|
return result;
|
|
532
|
-
};
|
|
533
|
-
var lint = ({
|
|
534
|
-
pkg,
|
|
535
|
-
verbose,
|
|
536
|
-
incremental,
|
|
537
|
-
fix: fix2
|
|
538
|
-
} = {}) => {
|
|
597
|
+
}, "lintPackage");
|
|
598
|
+
var lint = /* @__PURE__ */ __name(({ pkg, verbose, incremental, fix: fix2 } = {}) => {
|
|
539
599
|
return pkg === void 0 ? lintAllPackages({
|
|
540
600
|
verbose,
|
|
541
601
|
incremental,
|
|
542
602
|
fix: fix2
|
|
543
|
-
}) : lintPackage({
|
|
544
|
-
|
|
545
|
-
|
|
603
|
+
}) : lintPackage({
|
|
604
|
+
pkg,
|
|
605
|
+
fix: fix2
|
|
606
|
+
});
|
|
607
|
+
}, "lint");
|
|
608
|
+
var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2 = false } = {}) => {
|
|
546
609
|
console.log(chalk10.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
547
610
|
const start = Date.now();
|
|
548
|
-
const fixOptions = fix2 ? [
|
|
611
|
+
const fixOptions = fix2 ? [
|
|
612
|
+
"--fix"
|
|
613
|
+
] : [];
|
|
549
614
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
550
|
-
[
|
|
615
|
+
[
|
|
616
|
+
"yarn",
|
|
617
|
+
[
|
|
618
|
+
"eslint",
|
|
619
|
+
...fixOptions
|
|
620
|
+
]
|
|
621
|
+
]
|
|
551
622
|
]);
|
|
552
623
|
console.log(chalk10.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk10.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk10.gray("seconds")}`));
|
|
553
624
|
return result;
|
|
554
|
-
};
|
|
625
|
+
}, "lintAllPackages");
|
|
555
626
|
|
|
556
627
|
// src/actions/fix.ts
|
|
557
|
-
var fix = (params) => {
|
|
558
|
-
return lint({
|
|
559
|
-
|
|
628
|
+
var fix = /* @__PURE__ */ __name((params) => {
|
|
629
|
+
return lint({
|
|
630
|
+
...params,
|
|
631
|
+
fix: true
|
|
632
|
+
});
|
|
633
|
+
}, "fix");
|
|
560
634
|
|
|
561
635
|
// src/actions/knip.ts
|
|
562
|
-
var knip = () => {
|
|
563
|
-
return runSteps("Knip", [
|
|
564
|
-
|
|
636
|
+
var knip = /* @__PURE__ */ __name(() => {
|
|
637
|
+
return runSteps("Knip", [
|
|
638
|
+
[
|
|
639
|
+
"yarn",
|
|
640
|
+
[
|
|
641
|
+
"knip",
|
|
642
|
+
"--dependencies",
|
|
643
|
+
"--no-exit-code"
|
|
644
|
+
]
|
|
645
|
+
]
|
|
646
|
+
]);
|
|
647
|
+
}, "knip");
|
|
565
648
|
|
|
566
649
|
// src/actions/publint.ts
|
|
567
|
-
var publint = async ({ verbose, pkg }) => {
|
|
568
|
-
return pkg
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
}
|
|
650
|
+
var publint = /* @__PURE__ */ __name(async ({ verbose, pkg }) => {
|
|
651
|
+
return pkg === void 0 ? publintAll({
|
|
652
|
+
verbose
|
|
653
|
+
}) : await publintPackage({
|
|
654
|
+
pkg,
|
|
655
|
+
verbose
|
|
656
|
+
});
|
|
657
|
+
}, "publint");
|
|
658
|
+
var publintPackage = /* @__PURE__ */ __name(({ pkg }) => {
|
|
659
|
+
return runStepsAsync(`Publint [${pkg}]`, [
|
|
660
|
+
[
|
|
661
|
+
"yarn",
|
|
662
|
+
[
|
|
663
|
+
"workspace",
|
|
664
|
+
pkg,
|
|
665
|
+
"run",
|
|
666
|
+
"package-publint"
|
|
667
|
+
]
|
|
668
|
+
]
|
|
669
|
+
]);
|
|
670
|
+
}, "publintPackage");
|
|
671
|
+
var publintAll = /* @__PURE__ */ __name(({ verbose }) => {
|
|
672
|
+
const verboseOptions = verbose ? [
|
|
673
|
+
"--verbose"
|
|
674
|
+
] : [
|
|
675
|
+
"--no-verbose"
|
|
676
|
+
];
|
|
677
|
+
return runSteps("Publint", [
|
|
678
|
+
[
|
|
679
|
+
"yarn",
|
|
680
|
+
[
|
|
681
|
+
"workspaces",
|
|
682
|
+
"foreach",
|
|
683
|
+
"-pA",
|
|
684
|
+
...verboseOptions,
|
|
685
|
+
"run",
|
|
686
|
+
"package-publint"
|
|
687
|
+
]
|
|
688
|
+
]
|
|
689
|
+
]);
|
|
690
|
+
}, "publintAll");
|
|
577
691
|
|
|
578
692
|
// src/actions/relint.ts
|
|
579
693
|
import chalk11 from "chalk";
|
|
580
|
-
var relintPackage = ({ pkg }) => {
|
|
694
|
+
var relintPackage = /* @__PURE__ */ __name(({ pkg }) => {
|
|
581
695
|
console.log(chalk11.gray(`${"Relint"} [All-Packages]`));
|
|
582
696
|
const start = Date.now();
|
|
583
697
|
const result = runSteps("Relint [All-Packages]", [
|
|
584
|
-
[
|
|
585
|
-
"
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
698
|
+
[
|
|
699
|
+
"yarn",
|
|
700
|
+
[
|
|
701
|
+
"workspace",
|
|
702
|
+
pkg,
|
|
703
|
+
"run",
|
|
704
|
+
"package-relint"
|
|
705
|
+
]
|
|
706
|
+
]
|
|
590
707
|
]);
|
|
591
708
|
console.log(chalk11.gray(`${"Relinted in"} [${chalk11.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk11.gray("seconds")}`));
|
|
592
709
|
return result;
|
|
593
|
-
};
|
|
594
|
-
var relint = ({
|
|
595
|
-
pkg
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
};
|
|
601
|
-
|
|
710
|
+
}, "relintPackage");
|
|
711
|
+
var relint = /* @__PURE__ */ __name(({ pkg, verbose, incremental } = {}) => {
|
|
712
|
+
return pkg ? relintPackage({
|
|
713
|
+
pkg
|
|
714
|
+
}) : relintAllPackages({
|
|
715
|
+
verbose,
|
|
716
|
+
incremental
|
|
717
|
+
});
|
|
718
|
+
}, "relint");
|
|
719
|
+
var relintAllPackages = /* @__PURE__ */ __name(({ verbose = false, incremental } = {}) => {
|
|
602
720
|
console.log(chalk11.gray(`${"Relint"} [All-Packages]`));
|
|
603
721
|
const start = Date.now();
|
|
604
|
-
const verboseOptions = verbose ? [
|
|
605
|
-
|
|
722
|
+
const verboseOptions = verbose ? [
|
|
723
|
+
"--verbose"
|
|
724
|
+
] : [
|
|
725
|
+
"--no-verbose"
|
|
726
|
+
];
|
|
727
|
+
const incrementalOptions = incremental ? [
|
|
728
|
+
"--since",
|
|
729
|
+
"-Ap"
|
|
730
|
+
] : [
|
|
731
|
+
"--parallel",
|
|
732
|
+
"-Ap"
|
|
733
|
+
];
|
|
606
734
|
const result = runSteps(`${"Relint"} [All-Packages]`, [
|
|
607
|
-
[
|
|
608
|
-
"
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
735
|
+
[
|
|
736
|
+
"yarn",
|
|
737
|
+
[
|
|
738
|
+
"workspaces",
|
|
739
|
+
"foreach",
|
|
740
|
+
...verboseOptions,
|
|
741
|
+
...incrementalOptions,
|
|
742
|
+
"run",
|
|
743
|
+
"package-relint"
|
|
744
|
+
]
|
|
745
|
+
]
|
|
615
746
|
]);
|
|
616
747
|
console.log(chalk11.gray(`Relinted in [${chalk11.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk11.gray("seconds")}`));
|
|
617
748
|
return result;
|
|
618
|
-
};
|
|
749
|
+
}, "relintAllPackages");
|
|
619
750
|
|
|
620
751
|
// src/actions/sonar.ts
|
|
621
|
-
var sonar = () => {
|
|
622
|
-
return runSteps("Sonar", [
|
|
623
|
-
|
|
752
|
+
var sonar = /* @__PURE__ */ __name(() => {
|
|
753
|
+
return runSteps("Sonar", [
|
|
754
|
+
[
|
|
755
|
+
"yarn",
|
|
756
|
+
[
|
|
757
|
+
"eslint",
|
|
758
|
+
"-c",
|
|
759
|
+
"sonar.eslintrc",
|
|
760
|
+
"."
|
|
761
|
+
]
|
|
762
|
+
]
|
|
763
|
+
]);
|
|
764
|
+
}, "sonar");
|
|
624
765
|
|
|
625
766
|
// src/xy/param.ts
|
|
626
|
-
var packagePositionalParam = (yargs) => {
|
|
627
|
-
return yargs.positional("package", {
|
|
628
|
-
|
|
767
|
+
var packagePositionalParam = /* @__PURE__ */ __name((yargs) => {
|
|
768
|
+
return yargs.positional("package", {
|
|
769
|
+
describe: "Specific package to target",
|
|
770
|
+
type: "string"
|
|
771
|
+
});
|
|
772
|
+
}, "packagePositionalParam");
|
|
629
773
|
|
|
630
774
|
// src/xy/xyLintCommands.ts
|
|
631
|
-
var xyLintCommands = (args) => {
|
|
632
|
-
return args.command(
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
(
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
(
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
(
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
|
|
733
|
-
}
|
|
734
|
-
).command(
|
|
735
|
-
"knip",
|
|
736
|
-
"Knip - Run Knip",
|
|
737
|
-
(yargs) => {
|
|
738
|
-
return packagePositionalParam(yargs);
|
|
739
|
-
},
|
|
740
|
-
(argv) => {
|
|
741
|
-
if (argv.verbose) console.log("Knip");
|
|
742
|
-
const start = Date.now();
|
|
743
|
-
process.exitCode = knip();
|
|
744
|
-
console.log(chalk12.blue(`Knip finished in ${Date.now() - start}ms`));
|
|
745
|
-
}
|
|
746
|
-
).command(
|
|
747
|
-
"sonar",
|
|
748
|
-
"Sonar - Run Sonar Check",
|
|
749
|
-
(yargs) => {
|
|
750
|
-
return packagePositionalParam(yargs);
|
|
751
|
-
},
|
|
752
|
-
(argv) => {
|
|
753
|
-
const start = Date.now();
|
|
754
|
-
if (argv.verbose) console.log("Sonar Check");
|
|
755
|
-
process.exitCode = sonar();
|
|
756
|
-
console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
|
|
757
|
-
}
|
|
758
|
-
);
|
|
759
|
-
};
|
|
775
|
+
var xyLintCommands = /* @__PURE__ */ __name((args) => {
|
|
776
|
+
return args.command("cycle [package]", "Cycle - Check for dependency cycles", (yargs) => {
|
|
777
|
+
return packagePositionalParam(yargs);
|
|
778
|
+
}, async (argv) => {
|
|
779
|
+
const start = Date.now();
|
|
780
|
+
if (argv.verbose) console.log("Cycle");
|
|
781
|
+
process.exitCode = await cycle({
|
|
782
|
+
pkg: argv.package
|
|
783
|
+
});
|
|
784
|
+
console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
|
|
785
|
+
}).command("lint [package]", "Lint - Run Eslint", (yargs) => {
|
|
786
|
+
return packagePositionalParam(yargs).option("fix", {
|
|
787
|
+
alias: "f",
|
|
788
|
+
default: false,
|
|
789
|
+
description: "Fix fixable issues",
|
|
790
|
+
type: "boolean"
|
|
791
|
+
}).option("cache", {
|
|
792
|
+
alias: "c",
|
|
793
|
+
default: false,
|
|
794
|
+
description: "Use caching for performance",
|
|
795
|
+
type: "boolean"
|
|
796
|
+
});
|
|
797
|
+
}, (argv) => {
|
|
798
|
+
if (argv.verbose) console.log("Lint");
|
|
799
|
+
const start = Date.now();
|
|
800
|
+
process.exitCode = argv.fix ? fix({
|
|
801
|
+
pkg: argv.package,
|
|
802
|
+
cache: argv.cache
|
|
803
|
+
}) : lint({
|
|
804
|
+
pkg: argv.package,
|
|
805
|
+
cache: argv.cache
|
|
806
|
+
});
|
|
807
|
+
console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
|
|
808
|
+
}).command("deplint [package]", "Deplint - Run Deplint", (yargs) => {
|
|
809
|
+
return packagePositionalParam(yargs).option("deps", {
|
|
810
|
+
alias: "d",
|
|
811
|
+
default: false,
|
|
812
|
+
description: "Check dependencies",
|
|
813
|
+
type: "boolean"
|
|
814
|
+
}).option("devDeps", {
|
|
815
|
+
alias: "v",
|
|
816
|
+
default: false,
|
|
817
|
+
description: "Check devDependencies",
|
|
818
|
+
type: "boolean"
|
|
819
|
+
}).option("peerDeps", {
|
|
820
|
+
alias: "p",
|
|
821
|
+
default: false,
|
|
822
|
+
description: "Check peerDependencies",
|
|
823
|
+
type: "boolean"
|
|
824
|
+
});
|
|
825
|
+
}, (argv) => {
|
|
826
|
+
if (argv.verbose) console.log("Deplint");
|
|
827
|
+
const start = Date.now();
|
|
828
|
+
process.exitCode = deplint({
|
|
829
|
+
pkg: argv.package,
|
|
830
|
+
deps: !!argv.deps,
|
|
831
|
+
devDeps: !!argv.devDeps,
|
|
832
|
+
peerDeps: !!argv.peerDeps,
|
|
833
|
+
verbose: !!argv.verbose
|
|
834
|
+
});
|
|
835
|
+
console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
|
|
836
|
+
}).command("fix [package]", "Fix - Run Eslint w/fix", (yargs) => {
|
|
837
|
+
return packagePositionalParam(yargs);
|
|
838
|
+
}, (argv) => {
|
|
839
|
+
const start = Date.now();
|
|
840
|
+
if (argv.verbose) console.log("Fix");
|
|
841
|
+
process.exitCode = fix();
|
|
842
|
+
console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
|
|
843
|
+
}).command("relint [package]", "Relint - Clean & Lint", (yargs) => {
|
|
844
|
+
return packagePositionalParam(yargs);
|
|
845
|
+
}, (argv) => {
|
|
846
|
+
if (argv.verbose) console.log("Relinting");
|
|
847
|
+
const start = Date.now();
|
|
848
|
+
process.exitCode = relint();
|
|
849
|
+
console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
|
|
850
|
+
}).command("publint [package]", "Publint - Run Publint", (yargs) => {
|
|
851
|
+
return packagePositionalParam(yargs);
|
|
852
|
+
}, async (argv) => {
|
|
853
|
+
if (argv.verbose) console.log("Publint");
|
|
854
|
+
const start = Date.now();
|
|
855
|
+
process.exitCode = await publint({
|
|
856
|
+
pkg: argv.package,
|
|
857
|
+
verbose: !!argv.verbose
|
|
858
|
+
});
|
|
859
|
+
console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
|
|
860
|
+
}).command("knip", "Knip - Run Knip", (yargs) => {
|
|
861
|
+
return packagePositionalParam(yargs);
|
|
862
|
+
}, (argv) => {
|
|
863
|
+
if (argv.verbose) console.log("Knip");
|
|
864
|
+
const start = Date.now();
|
|
865
|
+
process.exitCode = knip();
|
|
866
|
+
console.log(chalk12.blue(`Knip finished in ${Date.now() - start}ms`));
|
|
867
|
+
}).command("sonar", "Sonar - Run Sonar Check", (yargs) => {
|
|
868
|
+
return packagePositionalParam(yargs);
|
|
869
|
+
}, (argv) => {
|
|
870
|
+
const start = Date.now();
|
|
871
|
+
if (argv.verbose) console.log("Sonar Check");
|
|
872
|
+
process.exitCode = sonar();
|
|
873
|
+
console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
|
|
874
|
+
});
|
|
875
|
+
}, "xyLintCommands");
|
|
760
876
|
export {
|
|
761
877
|
xyLintCommands
|
|
762
878
|
};
|