@xylabs/ts-scripts-yarn3 7.4.22 → 7.4.23
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/claude-settings.mjs +2 -2
- package/dist/actions/claude-settings.mjs.map +1 -1
- package/dist/actions/index.mjs +168 -12
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/package-lint.mjs +178 -0
- package/dist/actions/package-lint.mjs.map +1 -0
- package/dist/bin/xy.mjs +204 -32
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +205 -32
- package/dist/index.mjs.map +1 -1
- package/dist/xy/common/claude/index.mjs +2 -2
- package/dist/xy/common/claude/index.mjs.map +1 -1
- package/dist/xy/common/claude/initCommand.mjs +2 -2
- package/dist/xy/common/claude/initCommand.mjs.map +1 -1
- package/dist/xy/common/claude/settingsCommand.mjs +2 -2
- package/dist/xy/common/claude/settingsCommand.mjs.map +1 -1
- package/dist/xy/common/index.mjs +2 -2
- package/dist/xy/common/index.mjs.map +1 -1
- package/dist/xy/index.mjs +204 -32
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/lint/index.mjs +200 -22
- package/dist/xy/lint/index.mjs.map +1 -1
- package/dist/xy/lint/packageLintCommand.mjs +193 -0
- package/dist/xy/lint/packageLintCommand.mjs.map +1 -0
- package/dist/xy/xy.mjs +204 -32
- package/dist/xy/xy.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// src/lib/yarn/workspace/yarnWorkspaces.ts
|
|
2
|
+
import { spawnSync } from "child_process";
|
|
3
|
+
var yarnWorkspaces = () => {
|
|
4
|
+
const result = spawnSync("yarn", ["workspaces", "list", "--json", "--recursive"], { encoding: "utf8", shell: true });
|
|
5
|
+
if (result.error) {
|
|
6
|
+
throw result.error;
|
|
7
|
+
}
|
|
8
|
+
return result.stdout.toString().split("\n").slice(0, -1).map((item) => {
|
|
9
|
+
return JSON.parse(item);
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// src/lib/yarn/yarnInitCwd.ts
|
|
14
|
+
var INIT_CWD = () => {
|
|
15
|
+
if (!process.env.INIT_CWD) console.error("Missing INIT_CWD");
|
|
16
|
+
return process.env.INIT_CWD;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// src/actions/package-lint.ts
|
|
20
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
21
|
+
import PATH from "path";
|
|
22
|
+
import chalk from "chalk";
|
|
23
|
+
import picomatch from "picomatch";
|
|
24
|
+
function emptyResult() {
|
|
25
|
+
return {
|
|
26
|
+
errors: [],
|
|
27
|
+
fixable: [],
|
|
28
|
+
warnings: []
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function readRootPackageJson(cwd) {
|
|
32
|
+
const raw = readFileSync(PATH.resolve(cwd, "package.json"), "utf8");
|
|
33
|
+
return JSON.parse(raw);
|
|
34
|
+
}
|
|
35
|
+
function writeRootPackageJson(cwd, pkg) {
|
|
36
|
+
const path = PATH.resolve(cwd, "package.json");
|
|
37
|
+
writeFileSync(path, `${JSON.stringify(pkg, null, 2)}
|
|
38
|
+
`, "utf8");
|
|
39
|
+
}
|
|
40
|
+
function isMonorepo(pkg) {
|
|
41
|
+
const workspaces = pkg.workspaces;
|
|
42
|
+
return Array.isArray(workspaces) && workspaces.length > 0;
|
|
43
|
+
}
|
|
44
|
+
function checkPackagesFolder(workspaces) {
|
|
45
|
+
const result = emptyResult();
|
|
46
|
+
for (const { location, name } of workspaces) {
|
|
47
|
+
if (location === ".") continue;
|
|
48
|
+
if (!location.startsWith("packages/") && !location.startsWith("packages\\")) {
|
|
49
|
+
result.errors.push(`${name} (${location}) is not inside a packages/ folder`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
function checkRootPrivate(pkg) {
|
|
55
|
+
const result = emptyResult();
|
|
56
|
+
if (!pkg.private) {
|
|
57
|
+
result.fixable.push("Root package.json must be private to prevent accidental publishing");
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
function fixRootPrivate(cwd, pkg) {
|
|
62
|
+
pkg.private = true;
|
|
63
|
+
writeRootPackageJson(cwd, pkg);
|
|
64
|
+
console.log(chalk.green(' \u2714 Fixed: set "private": true in root package.json'));
|
|
65
|
+
}
|
|
66
|
+
function checkNoPublishConfigOnPrivate(pkg) {
|
|
67
|
+
const result = emptyResult();
|
|
68
|
+
if (pkg.private && pkg.publishConfig) {
|
|
69
|
+
result.fixable.push("Root package.json has publishConfig but is private \u2014 publishConfig is unnecessary");
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
function fixNoPublishConfigOnPrivate(cwd, pkg) {
|
|
74
|
+
delete pkg.publishConfig;
|
|
75
|
+
writeRootPackageJson(cwd, pkg);
|
|
76
|
+
console.log(chalk.green(" \u2714 Fixed: removed publishConfig from private root package.json"));
|
|
77
|
+
}
|
|
78
|
+
function checkDiscoverable(pkg, workspaces) {
|
|
79
|
+
const result = emptyResult();
|
|
80
|
+
const globs = pkg.workspaces;
|
|
81
|
+
const matchers = globs.map((glob) => picomatch(glob));
|
|
82
|
+
const isMatch = (location) => matchers.some((m) => m(location));
|
|
83
|
+
for (const { location, name } of workspaces) {
|
|
84
|
+
if (location === ".") continue;
|
|
85
|
+
if (!isMatch(location)) {
|
|
86
|
+
result.errors.push(`${name} (${location}) is not matched by any workspace glob in package.json`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
function logResults(label, result, fix) {
|
|
92
|
+
let errors = 0;
|
|
93
|
+
let fixed = 0;
|
|
94
|
+
for (const error of result.errors) {
|
|
95
|
+
console.log(chalk.red(` \u2717 ${error}`));
|
|
96
|
+
errors++;
|
|
97
|
+
}
|
|
98
|
+
for (const fixable of result.fixable) {
|
|
99
|
+
if (fix) {
|
|
100
|
+
fixed++;
|
|
101
|
+
} else {
|
|
102
|
+
console.log(chalk.red(` \u2717 ${fixable} (fixable)`));
|
|
103
|
+
errors++;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
for (const warning of result.warnings) {
|
|
107
|
+
console.log(chalk.yellow(` \u26A0 ${warning}`));
|
|
108
|
+
}
|
|
109
|
+
if (errors === 0 && fixed === 0 && result.warnings.length === 0) {
|
|
110
|
+
console.log(chalk.green(` \u2713 ${label}`));
|
|
111
|
+
}
|
|
112
|
+
return { errors, fixed };
|
|
113
|
+
}
|
|
114
|
+
function runChecks(entries, cwd, pkg, fix) {
|
|
115
|
+
let totalErrors = 0;
|
|
116
|
+
let totalFixed = 0;
|
|
117
|
+
for (const entry of entries) {
|
|
118
|
+
const result = entry.check();
|
|
119
|
+
const log = logResults(entry.label, result, fix);
|
|
120
|
+
if (fix && entry.fix && result.fixable.length > 0) {
|
|
121
|
+
entry.fix(cwd, pkg);
|
|
122
|
+
}
|
|
123
|
+
totalErrors += log.errors;
|
|
124
|
+
totalFixed += log.fixed;
|
|
125
|
+
}
|
|
126
|
+
return { errors: totalErrors, fixed: totalFixed };
|
|
127
|
+
}
|
|
128
|
+
function logSummary(errors, fixed) {
|
|
129
|
+
if (fixed > 0) {
|
|
130
|
+
console.log(chalk.green(`
|
|
131
|
+
Fixed ${fixed} issue(s)`));
|
|
132
|
+
}
|
|
133
|
+
if (errors > 0) {
|
|
134
|
+
console.log(chalk.red(`
|
|
135
|
+
${errors} error(s) found`));
|
|
136
|
+
} else if (fixed === 0) {
|
|
137
|
+
console.log(chalk.green("\n All checks passed"));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function packageLintMonorepo(fix = false) {
|
|
141
|
+
const cwd = INIT_CWD() ?? process.cwd();
|
|
142
|
+
let pkg;
|
|
143
|
+
try {
|
|
144
|
+
pkg = readRootPackageJson(cwd);
|
|
145
|
+
} catch {
|
|
146
|
+
console.error(chalk.red("Could not read package.json"));
|
|
147
|
+
return 1;
|
|
148
|
+
}
|
|
149
|
+
if (!isMonorepo(pkg)) {
|
|
150
|
+
console.log(chalk.gray("Not a monorepo \u2014 skipping package-lint checks"));
|
|
151
|
+
return 0;
|
|
152
|
+
}
|
|
153
|
+
console.log(chalk.green("Package Lint"));
|
|
154
|
+
const workspaces = yarnWorkspaces();
|
|
155
|
+
const checks = [
|
|
156
|
+
{
|
|
157
|
+
check: () => checkRootPrivate(pkg),
|
|
158
|
+
fix: fixRootPrivate,
|
|
159
|
+
label: "Root package is private"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
check: () => checkNoPublishConfigOnPrivate(pkg),
|
|
163
|
+
fix: fixNoPublishConfigOnPrivate,
|
|
164
|
+
label: "No publishConfig on private root"
|
|
165
|
+
},
|
|
166
|
+
{ check: () => checkPackagesFolder(workspaces), label: "All packages are in packages/ folder" },
|
|
167
|
+
{ check: () => checkDiscoverable(pkg, workspaces), label: "All packages are discoverable from workspace globs" }
|
|
168
|
+
];
|
|
169
|
+
const { errors, fixed } = runChecks(checks, cwd, pkg, fix);
|
|
170
|
+
logSummary(errors, fixed);
|
|
171
|
+
return errors > 0 ? 1 : 0;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/xy/lint/packageLintCommand.ts
|
|
175
|
+
var packageLintCommand = {
|
|
176
|
+
builder: (yargs) => {
|
|
177
|
+
return yargs.option("fix", {
|
|
178
|
+
default: false,
|
|
179
|
+
description: "Auto-fix fixable issues",
|
|
180
|
+
type: "boolean"
|
|
181
|
+
});
|
|
182
|
+
},
|
|
183
|
+
command: "package-lint",
|
|
184
|
+
describe: "Package Lint - Check monorepo package structure",
|
|
185
|
+
handler: (argv) => {
|
|
186
|
+
if (argv.verbose) console.log("Package Lint");
|
|
187
|
+
process.exitCode = packageLintMonorepo(!!argv.fix);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
export {
|
|
191
|
+
packageLintCommand
|
|
192
|
+
};
|
|
193
|
+
//# sourceMappingURL=packageLintCommand.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/yarn/workspace/yarnWorkspaces.ts","../../../src/lib/yarn/yarnInitCwd.ts","../../../src/actions/package-lint.ts","../../../src/xy/lint/packageLintCommand.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process'\n\nimport type { Workspace } from './Workspace.ts'\n\nexport const yarnWorkspaces = (): Workspace[] => {\n const result = spawnSync('yarn', ['workspaces', 'list', '--json', '--recursive'], { encoding: 'utf8', shell: true })\n if (result.error) {\n throw result.error\n }\n return (\n result.stdout\n .toString()\n // NOTE: This probably doesn't work on Windows\n // TODO: Replace /r/n with /n first\n .split('\\n')\n .slice(0, -1)\n .map((item) => {\n return JSON.parse(item)\n })\n )\n}\n","export const INIT_CWD = () => {\n if (!process.env.INIT_CWD) console.error('Missing INIT_CWD')\n return process.env.INIT_CWD\n}\n","import { readFileSync, writeFileSync } from 'node:fs'\nimport PATH from 'node:path'\n\nimport chalk from 'chalk'\nimport picomatch from 'picomatch'\n\nimport { INIT_CWD, yarnWorkspaces } from '../lib/yarn/index.ts'\n\ninterface LintResult {\n errors: string[]\n fixable: string[]\n warnings: string[]\n}\n\nfunction emptyResult(): LintResult {\n return {\n errors: [], fixable: [], warnings: [],\n }\n}\n\nfunction readRootPackageJson(cwd: string) {\n const raw = readFileSync(PATH.resolve(cwd, 'package.json'), 'utf8')\n return JSON.parse(raw)\n}\n\nfunction writeRootPackageJson(cwd: string, pkg: Record<string, unknown>) {\n const path = PATH.resolve(cwd, 'package.json')\n writeFileSync(path, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n}\n\nfunction isMonorepo(pkg: Record<string, unknown>): boolean {\n const workspaces = pkg.workspaces\n return Array.isArray(workspaces) && workspaces.length > 0\n}\n\nfunction checkPackagesFolder(workspaces: { location: string; name: string }[]): LintResult {\n const result = emptyResult()\n\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n if (!location.startsWith('packages/') && !location.startsWith('packages\\\\')) {\n result.errors.push(`${name} (${location}) is not inside a packages/ folder`)\n }\n }\n\n return result\n}\n\nfunction checkRootPrivate(pkg: Record<string, unknown>): LintResult {\n const result = emptyResult()\n\n if (!pkg.private) {\n result.fixable.push('Root package.json must be private to prevent accidental publishing')\n }\n\n return result\n}\n\nfunction fixRootPrivate(cwd: string, pkg: Record<string, unknown>) {\n pkg.private = true\n writeRootPackageJson(cwd, pkg)\n console.log(chalk.green(' ✔ Fixed: set \"private\": true in root package.json'))\n}\n\nfunction checkNoPublishConfigOnPrivate(pkg: Record<string, unknown>): LintResult {\n const result = emptyResult()\n\n if (pkg.private && pkg.publishConfig) {\n result.fixable.push('Root package.json has publishConfig but is private — publishConfig is unnecessary')\n }\n\n return result\n}\n\nfunction fixNoPublishConfigOnPrivate(cwd: string, pkg: Record<string, unknown>) {\n delete pkg.publishConfig\n writeRootPackageJson(cwd, pkg)\n console.log(chalk.green(' ✔ Fixed: removed publishConfig from private root package.json'))\n}\n\nfunction checkDiscoverable(\n pkg: Record<string, unknown>,\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result = emptyResult()\n\n const globs = pkg.workspaces as string[]\n const matchers = globs.map(glob => picomatch(glob))\n const isMatch = (location: string) => matchers.some(m => m(location))\n\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n if (!isMatch(location)) {\n result.errors.push(`${name} (${location}) is not matched by any workspace glob in package.json`)\n }\n }\n\n return result\n}\n\nfunction logResults(label: string, result: LintResult, fix: boolean): { errors: number; fixed: number } {\n let errors = 0\n let fixed = 0\n\n for (const error of result.errors) {\n console.log(chalk.red(` ✗ ${error}`))\n errors++\n }\n for (const fixable of result.fixable) {\n if (fix) {\n fixed++\n } else {\n console.log(chalk.red(` ✗ ${fixable} (fixable)`))\n errors++\n }\n }\n for (const warning of result.warnings) {\n console.log(chalk.yellow(` ⚠ ${warning}`))\n }\n if (errors === 0 && fixed === 0 && result.warnings.length === 0) {\n console.log(chalk.green(` ✓ ${label}`))\n }\n\n return { errors, fixed }\n}\n\ninterface CheckEntry {\n check: () => LintResult\n fix?: (cwd: string, pkg: Record<string, unknown>) => void\n label: string\n}\n\nfunction runChecks(entries: CheckEntry[], cwd: string, pkg: Record<string, unknown>, fix: boolean): { errors: number; fixed: number } {\n let totalErrors = 0\n let totalFixed = 0\n\n for (const entry of entries) {\n const result = entry.check()\n const log = logResults(entry.label, result, fix)\n if (fix && entry.fix && result.fixable.length > 0) {\n entry.fix(cwd, pkg)\n }\n totalErrors += log.errors\n totalFixed += log.fixed\n }\n\n return { errors: totalErrors, fixed: totalFixed }\n}\n\nfunction logSummary(errors: number, fixed: number) {\n if (fixed > 0) {\n console.log(chalk.green(`\\n Fixed ${fixed} issue(s)`))\n }\n if (errors > 0) {\n console.log(chalk.red(`\\n ${errors} error(s) found`))\n } else if (fixed === 0) {\n console.log(chalk.green('\\n All checks passed'))\n }\n}\n\nexport function packageLintMonorepo(fix = false): number {\n const cwd = INIT_CWD() ?? process.cwd()\n\n let pkg: Record<string, unknown>\n try {\n pkg = readRootPackageJson(cwd)\n } catch {\n console.error(chalk.red('Could not read package.json'))\n return 1\n }\n\n if (!isMonorepo(pkg)) {\n console.log(chalk.gray('Not a monorepo — skipping package-lint checks'))\n return 0\n }\n\n console.log(chalk.green('Package Lint'))\n\n const workspaces = yarnWorkspaces()\n\n const checks: CheckEntry[] = [\n {\n check: () => checkRootPrivate(pkg), fix: fixRootPrivate, label: 'Root package is private',\n },\n {\n check: () => checkNoPublishConfigOnPrivate(pkg), fix: fixNoPublishConfigOnPrivate, label: 'No publishConfig on private root',\n },\n { check: () => checkPackagesFolder(workspaces), label: 'All packages are in packages/ folder' },\n { check: () => checkDiscoverable(pkg, workspaces), label: 'All packages are discoverable from workspace globs' },\n ]\n\n const { errors, fixed } = runChecks(checks, cwd, pkg, fix)\n logSummary(errors, fixed)\n\n return errors > 0 ? 1 : 0\n}\n","import type { CommandModule } from 'yargs'\n\nimport { packageLintMonorepo } from '../../actions/index.ts'\n\nexport const packageLintCommand: CommandModule = {\n builder: (yargs) => {\n return yargs.option('fix', {\n default: false,\n description: 'Auto-fix fixable issues',\n type: 'boolean',\n })\n },\n command: 'package-lint',\n describe: 'Package Lint - Check monorepo package structure',\n handler: (argv) => {\n if (argv.verbose) console.log('Package Lint')\n process.exitCode = packageLintMonorepo(!!argv.fix)\n },\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAInB,IAAM,iBAAiB,MAAmB;AAC/C,QAAM,SAAS,UAAU,QAAQ,CAAC,cAAc,QAAQ,UAAU,aAAa,GAAG,EAAE,UAAU,QAAQ,OAAO,KAAK,CAAC;AACnH,MAAI,OAAO,OAAO;AAChB,UAAM,OAAO;AAAA,EACf;AACA,SACE,OAAO,OACJ,SAAS,EAGT,MAAM,IAAI,EACV,MAAM,GAAG,EAAE,EACX,IAAI,CAAC,SAAS;AACb,WAAO,KAAK,MAAM,IAAI;AAAA,EACxB,CAAC;AAEP;;;ACpBO,IAAM,WAAW,MAAM;AAC5B,MAAI,CAAC,QAAQ,IAAI,SAAU,SAAQ,MAAM,kBAAkB;AAC3D,SAAO,QAAQ,IAAI;AACrB;;;ACHA,SAAS,cAAc,qBAAqB;AAC5C,OAAO,UAAU;AAEjB,OAAO,WAAW;AAClB,OAAO,eAAe;AAUtB,SAAS,cAA0B;AACjC,SAAO;AAAA,IACL,QAAQ,CAAC;AAAA,IAAG,SAAS,CAAC;AAAA,IAAG,UAAU,CAAC;AAAA,EACtC;AACF;AAEA,SAAS,oBAAoB,KAAa;AACxC,QAAM,MAAM,aAAa,KAAK,QAAQ,KAAK,cAAc,GAAG,MAAM;AAClE,SAAO,KAAK,MAAM,GAAG;AACvB;AAEA,SAAS,qBAAqB,KAAa,KAA8B;AACvE,QAAM,OAAO,KAAK,QAAQ,KAAK,cAAc;AAC7C,gBAAc,MAAM,GAAG,KAAK,UAAU,KAAK,MAAM,CAAC,CAAC;AAAA,GAAM,MAAM;AACjE;AAE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AAA,EACA,SAAS;AAAA,EACT,UAAU;AAAA,EACV,SAAS,CAAC,SAAS;AACjB,QAAI,KAAK,QAAS,SAAQ,IAAI,cAAc;AAC5C,YAAQ,WAAW,oBAAoB,CAAC,CAAC,KAAK,GAAG;AAAA,EACnD;AACF;","names":[]}
|
package/dist/xy/xy.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/xy/xy.ts
|
|
2
|
-
import
|
|
2
|
+
import chalk42 from "chalk";
|
|
3
3
|
|
|
4
4
|
// src/actions/build.ts
|
|
5
5
|
import chalk9 from "chalk";
|
|
@@ -991,8 +991,8 @@ var DEFAULT_SETTINGS = {
|
|
|
991
991
|
"Skill"
|
|
992
992
|
],
|
|
993
993
|
deny: [
|
|
994
|
-
"Bash(git push --force*)",
|
|
995
|
-
"Bash(git reset --hard*)",
|
|
994
|
+
"Bash(git push --force *)",
|
|
995
|
+
"Bash(git reset --hard *)",
|
|
996
996
|
"Bash(rm -rf /*)"
|
|
997
997
|
]
|
|
998
998
|
}
|
|
@@ -2420,6 +2420,161 @@ var license = async (pkg) => {
|
|
|
2420
2420
|
var filename = ".npmignore";
|
|
2421
2421
|
var npmignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
2422
2422
|
|
|
2423
|
+
// src/actions/package-lint.ts
|
|
2424
|
+
import { readFileSync as readFileSync13, writeFileSync as writeFileSync6 } from "fs";
|
|
2425
|
+
import PATH9 from "path";
|
|
2426
|
+
import chalk30 from "chalk";
|
|
2427
|
+
import picomatch from "picomatch";
|
|
2428
|
+
function emptyResult() {
|
|
2429
|
+
return {
|
|
2430
|
+
errors: [],
|
|
2431
|
+
fixable: [],
|
|
2432
|
+
warnings: []
|
|
2433
|
+
};
|
|
2434
|
+
}
|
|
2435
|
+
function readRootPackageJson(cwd) {
|
|
2436
|
+
const raw = readFileSync13(PATH9.resolve(cwd, "package.json"), "utf8");
|
|
2437
|
+
return JSON.parse(raw);
|
|
2438
|
+
}
|
|
2439
|
+
function writeRootPackageJson(cwd, pkg) {
|
|
2440
|
+
const path8 = PATH9.resolve(cwd, "package.json");
|
|
2441
|
+
writeFileSync6(path8, `${JSON.stringify(pkg, null, 2)}
|
|
2442
|
+
`, "utf8");
|
|
2443
|
+
}
|
|
2444
|
+
function isMonorepo(pkg) {
|
|
2445
|
+
const workspaces = pkg.workspaces;
|
|
2446
|
+
return Array.isArray(workspaces) && workspaces.length > 0;
|
|
2447
|
+
}
|
|
2448
|
+
function checkPackagesFolder(workspaces) {
|
|
2449
|
+
const result = emptyResult();
|
|
2450
|
+
for (const { location, name } of workspaces) {
|
|
2451
|
+
if (location === ".") continue;
|
|
2452
|
+
if (!location.startsWith("packages/") && !location.startsWith("packages\\")) {
|
|
2453
|
+
result.errors.push(`${name} (${location}) is not inside a packages/ folder`);
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
return result;
|
|
2457
|
+
}
|
|
2458
|
+
function checkRootPrivate(pkg) {
|
|
2459
|
+
const result = emptyResult();
|
|
2460
|
+
if (!pkg.private) {
|
|
2461
|
+
result.fixable.push("Root package.json must be private to prevent accidental publishing");
|
|
2462
|
+
}
|
|
2463
|
+
return result;
|
|
2464
|
+
}
|
|
2465
|
+
function fixRootPrivate(cwd, pkg) {
|
|
2466
|
+
pkg.private = true;
|
|
2467
|
+
writeRootPackageJson(cwd, pkg);
|
|
2468
|
+
console.log(chalk30.green(' \u2714 Fixed: set "private": true in root package.json'));
|
|
2469
|
+
}
|
|
2470
|
+
function checkNoPublishConfigOnPrivate(pkg) {
|
|
2471
|
+
const result = emptyResult();
|
|
2472
|
+
if (pkg.private && pkg.publishConfig) {
|
|
2473
|
+
result.fixable.push("Root package.json has publishConfig but is private \u2014 publishConfig is unnecessary");
|
|
2474
|
+
}
|
|
2475
|
+
return result;
|
|
2476
|
+
}
|
|
2477
|
+
function fixNoPublishConfigOnPrivate(cwd, pkg) {
|
|
2478
|
+
delete pkg.publishConfig;
|
|
2479
|
+
writeRootPackageJson(cwd, pkg);
|
|
2480
|
+
console.log(chalk30.green(" \u2714 Fixed: removed publishConfig from private root package.json"));
|
|
2481
|
+
}
|
|
2482
|
+
function checkDiscoverable(pkg, workspaces) {
|
|
2483
|
+
const result = emptyResult();
|
|
2484
|
+
const globs = pkg.workspaces;
|
|
2485
|
+
const matchers = globs.map((glob2) => picomatch(glob2));
|
|
2486
|
+
const isMatch = (location) => matchers.some((m) => m(location));
|
|
2487
|
+
for (const { location, name } of workspaces) {
|
|
2488
|
+
if (location === ".") continue;
|
|
2489
|
+
if (!isMatch(location)) {
|
|
2490
|
+
result.errors.push(`${name} (${location}) is not matched by any workspace glob in package.json`);
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
return result;
|
|
2494
|
+
}
|
|
2495
|
+
function logResults(label, result, fix2) {
|
|
2496
|
+
let errors = 0;
|
|
2497
|
+
let fixed = 0;
|
|
2498
|
+
for (const error of result.errors) {
|
|
2499
|
+
console.log(chalk30.red(` \u2717 ${error}`));
|
|
2500
|
+
errors++;
|
|
2501
|
+
}
|
|
2502
|
+
for (const fixable of result.fixable) {
|
|
2503
|
+
if (fix2) {
|
|
2504
|
+
fixed++;
|
|
2505
|
+
} else {
|
|
2506
|
+
console.log(chalk30.red(` \u2717 ${fixable} (fixable)`));
|
|
2507
|
+
errors++;
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
for (const warning of result.warnings) {
|
|
2511
|
+
console.log(chalk30.yellow(` \u26A0 ${warning}`));
|
|
2512
|
+
}
|
|
2513
|
+
if (errors === 0 && fixed === 0 && result.warnings.length === 0) {
|
|
2514
|
+
console.log(chalk30.green(` \u2713 ${label}`));
|
|
2515
|
+
}
|
|
2516
|
+
return { errors, fixed };
|
|
2517
|
+
}
|
|
2518
|
+
function runChecks(entries, cwd, pkg, fix2) {
|
|
2519
|
+
let totalErrors = 0;
|
|
2520
|
+
let totalFixed = 0;
|
|
2521
|
+
for (const entry of entries) {
|
|
2522
|
+
const result = entry.check();
|
|
2523
|
+
const log = logResults(entry.label, result, fix2);
|
|
2524
|
+
if (fix2 && entry.fix && result.fixable.length > 0) {
|
|
2525
|
+
entry.fix(cwd, pkg);
|
|
2526
|
+
}
|
|
2527
|
+
totalErrors += log.errors;
|
|
2528
|
+
totalFixed += log.fixed;
|
|
2529
|
+
}
|
|
2530
|
+
return { errors: totalErrors, fixed: totalFixed };
|
|
2531
|
+
}
|
|
2532
|
+
function logSummary(errors, fixed) {
|
|
2533
|
+
if (fixed > 0) {
|
|
2534
|
+
console.log(chalk30.green(`
|
|
2535
|
+
Fixed ${fixed} issue(s)`));
|
|
2536
|
+
}
|
|
2537
|
+
if (errors > 0) {
|
|
2538
|
+
console.log(chalk30.red(`
|
|
2539
|
+
${errors} error(s) found`));
|
|
2540
|
+
} else if (fixed === 0) {
|
|
2541
|
+
console.log(chalk30.green("\n All checks passed"));
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
function packageLintMonorepo(fix2 = false) {
|
|
2545
|
+
const cwd = INIT_CWD() ?? process.cwd();
|
|
2546
|
+
let pkg;
|
|
2547
|
+
try {
|
|
2548
|
+
pkg = readRootPackageJson(cwd);
|
|
2549
|
+
} catch {
|
|
2550
|
+
console.error(chalk30.red("Could not read package.json"));
|
|
2551
|
+
return 1;
|
|
2552
|
+
}
|
|
2553
|
+
if (!isMonorepo(pkg)) {
|
|
2554
|
+
console.log(chalk30.gray("Not a monorepo \u2014 skipping package-lint checks"));
|
|
2555
|
+
return 0;
|
|
2556
|
+
}
|
|
2557
|
+
console.log(chalk30.green("Package Lint"));
|
|
2558
|
+
const workspaces = yarnWorkspaces();
|
|
2559
|
+
const checks = [
|
|
2560
|
+
{
|
|
2561
|
+
check: () => checkRootPrivate(pkg),
|
|
2562
|
+
fix: fixRootPrivate,
|
|
2563
|
+
label: "Root package is private"
|
|
2564
|
+
},
|
|
2565
|
+
{
|
|
2566
|
+
check: () => checkNoPublishConfigOnPrivate(pkg),
|
|
2567
|
+
fix: fixNoPublishConfigOnPrivate,
|
|
2568
|
+
label: "No publishConfig on private root"
|
|
2569
|
+
},
|
|
2570
|
+
{ check: () => checkPackagesFolder(workspaces), label: "All packages are in packages/ folder" },
|
|
2571
|
+
{ check: () => checkDiscoverable(pkg, workspaces), label: "All packages are discoverable from workspace globs" }
|
|
2572
|
+
];
|
|
2573
|
+
const { errors, fixed } = runChecks(checks, cwd, pkg, fix2);
|
|
2574
|
+
logSummary(errors, fixed);
|
|
2575
|
+
return errors > 0 ? 1 : 0;
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2423
2578
|
// src/actions/publint.ts
|
|
2424
2579
|
var publint = async ({ verbose, pkg }) => {
|
|
2425
2580
|
return pkg === void 0 ? publintAll({ verbose }) : await publintPackage({ pkg, verbose });
|
|
@@ -2473,7 +2628,7 @@ var rebuild = ({ target }) => {
|
|
|
2473
2628
|
};
|
|
2474
2629
|
|
|
2475
2630
|
// src/actions/recompile.ts
|
|
2476
|
-
import
|
|
2631
|
+
import chalk31 from "chalk";
|
|
2477
2632
|
var recompile = async ({
|
|
2478
2633
|
verbose,
|
|
2479
2634
|
target,
|
|
@@ -2509,7 +2664,7 @@ var recompileAll = async ({
|
|
|
2509
2664
|
const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
|
|
2510
2665
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
2511
2666
|
if (jobs) {
|
|
2512
|
-
console.log(
|
|
2667
|
+
console.log(chalk31.blue(`Jobs set to [${jobs}]`));
|
|
2513
2668
|
}
|
|
2514
2669
|
const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
|
|
2515
2670
|
[
|
|
@@ -2540,7 +2695,7 @@ var recompileAll = async ({
|
|
|
2540
2695
|
]
|
|
2541
2696
|
]);
|
|
2542
2697
|
console.log(
|
|
2543
|
-
`${
|
|
2698
|
+
`${chalk31.gray("Recompiled in")} [${chalk31.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk31.gray("seconds")}`
|
|
2544
2699
|
);
|
|
2545
2700
|
return result;
|
|
2546
2701
|
};
|
|
@@ -2571,13 +2726,13 @@ var reinstall = () => {
|
|
|
2571
2726
|
};
|
|
2572
2727
|
|
|
2573
2728
|
// src/actions/relint.ts
|
|
2574
|
-
import
|
|
2729
|
+
import chalk32 from "chalk";
|
|
2575
2730
|
var relintPackage = ({
|
|
2576
2731
|
pkg,
|
|
2577
2732
|
fix: fix2,
|
|
2578
2733
|
verbose
|
|
2579
2734
|
}) => {
|
|
2580
|
-
console.log(
|
|
2735
|
+
console.log(chalk32.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
2581
2736
|
const start = Date.now();
|
|
2582
2737
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
2583
2738
|
["yarn", [
|
|
@@ -2587,7 +2742,7 @@ var relintPackage = ({
|
|
|
2587
2742
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
2588
2743
|
]]
|
|
2589
2744
|
]);
|
|
2590
|
-
console.log(
|
|
2745
|
+
console.log(chalk32.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk32.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk32.gray("seconds")}`));
|
|
2591
2746
|
return result;
|
|
2592
2747
|
};
|
|
2593
2748
|
var relint = ({
|
|
@@ -2607,13 +2762,13 @@ var relint = ({
|
|
|
2607
2762
|
});
|
|
2608
2763
|
};
|
|
2609
2764
|
var relintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
2610
|
-
console.log(
|
|
2765
|
+
console.log(chalk32.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
2611
2766
|
const start = Date.now();
|
|
2612
2767
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
2613
2768
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
2614
2769
|
["yarn", ["eslint", ...fixOptions]]
|
|
2615
2770
|
]);
|
|
2616
|
-
console.log(
|
|
2771
|
+
console.log(chalk32.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk32.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk32.gray("seconds")}`));
|
|
2617
2772
|
return result;
|
|
2618
2773
|
};
|
|
2619
2774
|
|
|
@@ -2631,10 +2786,10 @@ var sonar = () => {
|
|
|
2631
2786
|
};
|
|
2632
2787
|
|
|
2633
2788
|
// src/actions/statics.ts
|
|
2634
|
-
import
|
|
2789
|
+
import chalk33 from "chalk";
|
|
2635
2790
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
2636
2791
|
var statics = () => {
|
|
2637
|
-
console.log(
|
|
2792
|
+
console.log(chalk33.green("Check Required Static Dependencies"));
|
|
2638
2793
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
2639
2794
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
2640
2795
|
};
|
|
@@ -3215,7 +3370,7 @@ var xyInstallCommands = (args) => {
|
|
|
3215
3370
|
};
|
|
3216
3371
|
|
|
3217
3372
|
// src/xy/lint/cycleCommand.ts
|
|
3218
|
-
import
|
|
3373
|
+
import chalk34 from "chalk";
|
|
3219
3374
|
var cycleCommand = {
|
|
3220
3375
|
command: "cycle [package]",
|
|
3221
3376
|
describe: "Cycle - Check for dependency cycles",
|
|
@@ -3226,12 +3381,12 @@ var cycleCommand = {
|
|
|
3226
3381
|
const start = Date.now();
|
|
3227
3382
|
if (argv.verbose) console.log("Cycle");
|
|
3228
3383
|
process.exitCode = await cycle({ pkg: argv.package });
|
|
3229
|
-
console.log(
|
|
3384
|
+
console.log(chalk34.blue(`Finished in ${Date.now() - start}ms`));
|
|
3230
3385
|
}
|
|
3231
3386
|
};
|
|
3232
3387
|
|
|
3233
3388
|
// src/xy/lint/deplintCommand.ts
|
|
3234
|
-
import
|
|
3389
|
+
import chalk35 from "chalk";
|
|
3235
3390
|
var deplintCommand = {
|
|
3236
3391
|
command: "deplint [package]",
|
|
3237
3392
|
describe: "Deplint - Run Deplint",
|
|
@@ -3269,12 +3424,12 @@ var deplintCommand = {
|
|
|
3269
3424
|
peerDeps: !!argv.peerDeps,
|
|
3270
3425
|
verbose: !!argv.verbose
|
|
3271
3426
|
});
|
|
3272
|
-
console.log(
|
|
3427
|
+
console.log(chalk35.blue(`Finished in ${Date.now() - start}ms`));
|
|
3273
3428
|
}
|
|
3274
3429
|
};
|
|
3275
3430
|
|
|
3276
3431
|
// src/xy/lint/fixCommand.ts
|
|
3277
|
-
import
|
|
3432
|
+
import chalk36 from "chalk";
|
|
3278
3433
|
var fixCommand = {
|
|
3279
3434
|
command: "fix [package]",
|
|
3280
3435
|
describe: "Fix - Run Eslint w/fix",
|
|
@@ -3285,12 +3440,12 @@ var fixCommand = {
|
|
|
3285
3440
|
const start = Date.now();
|
|
3286
3441
|
if (argv.verbose) console.log("Fix");
|
|
3287
3442
|
process.exitCode = fix();
|
|
3288
|
-
console.log(
|
|
3443
|
+
console.log(chalk36.blue(`Finished in ${Date.now() - start}ms`));
|
|
3289
3444
|
}
|
|
3290
3445
|
};
|
|
3291
3446
|
|
|
3292
3447
|
// src/xy/lint/knipCommand.ts
|
|
3293
|
-
import
|
|
3448
|
+
import chalk37 from "chalk";
|
|
3294
3449
|
var knipCommand = {
|
|
3295
3450
|
command: "knip",
|
|
3296
3451
|
describe: "Knip - Run Knip",
|
|
@@ -3301,12 +3456,12 @@ var knipCommand = {
|
|
|
3301
3456
|
if (argv.verbose) console.log("Knip");
|
|
3302
3457
|
const start = Date.now();
|
|
3303
3458
|
process.exitCode = knip();
|
|
3304
|
-
console.log(
|
|
3459
|
+
console.log(chalk37.blue(`Knip finished in ${Date.now() - start}ms`));
|
|
3305
3460
|
}
|
|
3306
3461
|
};
|
|
3307
3462
|
|
|
3308
3463
|
// src/xy/lint/lintCommand.ts
|
|
3309
|
-
import
|
|
3464
|
+
import chalk38 from "chalk";
|
|
3310
3465
|
var lintCommand = {
|
|
3311
3466
|
command: "lint [package]",
|
|
3312
3467
|
describe: "Lint - Run Eslint",
|
|
@@ -3335,12 +3490,29 @@ var lintCommand = {
|
|
|
3335
3490
|
cache: argv.cache,
|
|
3336
3491
|
verbose: !!argv.verbose
|
|
3337
3492
|
});
|
|
3338
|
-
console.log(
|
|
3493
|
+
console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
|
|
3494
|
+
}
|
|
3495
|
+
};
|
|
3496
|
+
|
|
3497
|
+
// src/xy/lint/packageLintCommand.ts
|
|
3498
|
+
var packageLintCommand = {
|
|
3499
|
+
builder: (yargs2) => {
|
|
3500
|
+
return yargs2.option("fix", {
|
|
3501
|
+
default: false,
|
|
3502
|
+
description: "Auto-fix fixable issues",
|
|
3503
|
+
type: "boolean"
|
|
3504
|
+
});
|
|
3505
|
+
},
|
|
3506
|
+
command: "package-lint",
|
|
3507
|
+
describe: "Package Lint - Check monorepo package structure",
|
|
3508
|
+
handler: (argv) => {
|
|
3509
|
+
if (argv.verbose) console.log("Package Lint");
|
|
3510
|
+
process.exitCode = packageLintMonorepo(!!argv.fix);
|
|
3339
3511
|
}
|
|
3340
3512
|
};
|
|
3341
3513
|
|
|
3342
3514
|
// src/xy/lint/publintCommand.ts
|
|
3343
|
-
import
|
|
3515
|
+
import chalk39 from "chalk";
|
|
3344
3516
|
var publintCommand = {
|
|
3345
3517
|
command: "publint [package]",
|
|
3346
3518
|
describe: "Publint - Run Publint",
|
|
@@ -3351,12 +3523,12 @@ var publintCommand = {
|
|
|
3351
3523
|
if (argv.verbose) console.log("Publint");
|
|
3352
3524
|
const start = Date.now();
|
|
3353
3525
|
process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
|
|
3354
|
-
console.log(
|
|
3526
|
+
console.log(chalk39.blue(`Finished in ${Date.now() - start}ms`));
|
|
3355
3527
|
}
|
|
3356
3528
|
};
|
|
3357
3529
|
|
|
3358
3530
|
// src/xy/lint/relintCommand.ts
|
|
3359
|
-
import
|
|
3531
|
+
import chalk40 from "chalk";
|
|
3360
3532
|
var relintCommand = {
|
|
3361
3533
|
command: "relint [package]",
|
|
3362
3534
|
describe: "Relint - Clean & Lint",
|
|
@@ -3367,12 +3539,12 @@ var relintCommand = {
|
|
|
3367
3539
|
if (argv.verbose) console.log("Relinting");
|
|
3368
3540
|
const start = Date.now();
|
|
3369
3541
|
process.exitCode = relint();
|
|
3370
|
-
console.log(
|
|
3542
|
+
console.log(chalk40.blue(`Finished in ${Date.now() - start}ms`));
|
|
3371
3543
|
}
|
|
3372
3544
|
};
|
|
3373
3545
|
|
|
3374
3546
|
// src/xy/lint/sonarCommand.ts
|
|
3375
|
-
import
|
|
3547
|
+
import chalk41 from "chalk";
|
|
3376
3548
|
var sonarCommand = {
|
|
3377
3549
|
command: "sonar",
|
|
3378
3550
|
describe: "Sonar - Run Sonar Check",
|
|
@@ -3383,13 +3555,13 @@ var sonarCommand = {
|
|
|
3383
3555
|
const start = Date.now();
|
|
3384
3556
|
if (argv.verbose) console.log("Sonar Check");
|
|
3385
3557
|
process.exitCode = sonar();
|
|
3386
|
-
console.log(
|
|
3558
|
+
console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
|
|
3387
3559
|
}
|
|
3388
3560
|
};
|
|
3389
3561
|
|
|
3390
3562
|
// src/xy/lint/index.ts
|
|
3391
3563
|
var xyLintCommands = (args) => {
|
|
3392
|
-
return args.command(cycleCommand).command(lintCommand).command(deplintCommand).command(fixCommand).command(relintCommand).command(publintCommand).command(knipCommand).command(sonarCommand);
|
|
3564
|
+
return args.command(cycleCommand).command(lintCommand).command(deplintCommand).command(fixCommand).command(relintCommand).command(publintCommand).command(knipCommand).command(packageLintCommand).command(sonarCommand);
|
|
3393
3565
|
};
|
|
3394
3566
|
|
|
3395
3567
|
// src/xy/xyParseOptions.ts
|
|
@@ -3423,8 +3595,8 @@ var xyParseOptions = () => {
|
|
|
3423
3595
|
var xy = async () => {
|
|
3424
3596
|
const options = xyParseOptions();
|
|
3425
3597
|
return await xyBuildCommands(xyCommonCommands(xyInstallCommands(xyDeployCommands(xyLintCommands(options))))).demandCommand(1).command("*", "", () => {
|
|
3426
|
-
console.error(
|
|
3427
|
-
console.log(
|
|
3598
|
+
console.error(chalk42.yellow(`Command not found [${chalk42.magenta(process.argv[2])}]`));
|
|
3599
|
+
console.log(chalk42.gray("Try 'yarn xy --help' for list of commands"));
|
|
3428
3600
|
}).version().help().argv;
|
|
3429
3601
|
};
|
|
3430
3602
|
export {
|