@produck/agent-toolkit 0.9.0 → 0.9.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/bin/command/sync-lint/index.mjs +66 -38
- package/package.json +2 -2
|
@@ -54,16 +54,27 @@ function readFileIfExists(filePath) {
|
|
|
54
54
|
return fs.readFileSync(filePath, 'utf8');
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
const ESLINT_TOOLING_PACKAGE_NAMES = [
|
|
58
|
+
'eslint',
|
|
59
|
+
'@eslint/js',
|
|
60
|
+
'@eslint/json',
|
|
61
|
+
'@eslint/markdown',
|
|
62
|
+
'@eslint/config-helpers',
|
|
63
|
+
'typescript-eslint',
|
|
64
|
+
'globals',
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
function getRequiredEslintDevDependencies() {
|
|
68
|
+
// Prefer the in-tree source of truth for @produck/eslint-rules: when
|
|
69
|
+
// sync-lint runs inside the monorepo, eslint-rules/package.json is
|
|
70
|
+
// authoritative. When running as an installed dependency, fall back to the
|
|
71
|
+
// publish-assets tooling baseline.
|
|
63
72
|
const inTreeEslintRulesPkgPath = path.resolve(
|
|
64
73
|
REPO_ROOT,
|
|
65
74
|
'packages/eslint-rules/package.json',
|
|
66
75
|
);
|
|
76
|
+
|
|
77
|
+
let eslintRulesVersion = '';
|
|
67
78
|
if (fs.existsSync(inTreeEslintRulesPkgPath)) {
|
|
68
79
|
const eslintRulesPkg = parseJsonFile(
|
|
69
80
|
inTreeEslintRulesPkgPath,
|
|
@@ -71,13 +82,13 @@ function getRequiredEslintRulesDevDependency() {
|
|
|
71
82
|
);
|
|
72
83
|
// The '' fallback is for when the in-tree package.json has a non-string
|
|
73
84
|
// version field, which never occurs for this package.
|
|
74
|
-
const
|
|
85
|
+
const v =
|
|
75
86
|
typeof eslintRulesPkg.version === 'string'
|
|
76
87
|
? eslintRulesPkg.version.trim()
|
|
77
88
|
: /* c8 ignore next */
|
|
78
89
|
'';
|
|
79
|
-
if (
|
|
80
|
-
|
|
90
|
+
if (v) {
|
|
91
|
+
eslintRulesVersion = v;
|
|
81
92
|
}
|
|
82
93
|
}
|
|
83
94
|
|
|
@@ -87,9 +98,9 @@ function getRequiredEslintRulesDevDependency() {
|
|
|
87
98
|
},
|
|
88
99
|
);
|
|
89
100
|
|
|
101
|
+
/* c8 ignore next 7 */
|
|
90
102
|
if (!toolingBaselinePath) {
|
|
91
|
-
console.error('Cannot resolve
|
|
92
|
-
console.error(`- ${inTreeEslintRulesPkgPath}`);
|
|
103
|
+
console.error('Cannot resolve ESLint tooling versions. Looked at:');
|
|
93
104
|
for (const candidatePath of TOOLING_BASELINE_CANDIDATE_PATHS) {
|
|
94
105
|
console.error(`- ${candidatePath}`);
|
|
95
106
|
}
|
|
@@ -97,21 +108,40 @@ function getRequiredEslintRulesDevDependency() {
|
|
|
97
108
|
}
|
|
98
109
|
|
|
99
110
|
const baseline = parseJsonFile(toolingBaselinePath, 'Tooling baseline file');
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
|
|
112
|
+
/* c8 ignore next 12 */
|
|
113
|
+
if (!eslintRulesVersion) {
|
|
114
|
+
const entry = baseline?.tools?.[ESLINT_RULES_PACKAGE_NAME];
|
|
115
|
+
const v = typeof entry?.version === 'string' ? entry.version.trim() : '';
|
|
116
|
+
if (!v) {
|
|
117
|
+
console.error(
|
|
118
|
+
`Tooling baseline tools["${ESLINT_RULES_PACKAGE_NAME}"].version must be a non-empty string: ${toolingBaselinePath}`,
|
|
119
|
+
);
|
|
120
|
+
process.exit(2);
|
|
121
|
+
}
|
|
122
|
+
eslintRulesVersion = v;
|
|
112
123
|
}
|
|
113
124
|
|
|
114
|
-
|
|
125
|
+
const deps = { [ESLINT_RULES_PACKAGE_NAME]: eslintRulesVersion };
|
|
126
|
+
|
|
127
|
+
for (const name of ESLINT_TOOLING_PACKAGE_NAMES) {
|
|
128
|
+
const entry = baseline?.tools?.[name];
|
|
129
|
+
const v =
|
|
130
|
+
typeof entry?.version === 'string'
|
|
131
|
+
? entry.version.trim()
|
|
132
|
+
: /* c8 ignore next */
|
|
133
|
+
'';
|
|
134
|
+
/* c8 ignore next 6 */
|
|
135
|
+
if (!v) {
|
|
136
|
+
console.error(
|
|
137
|
+
`Tooling baseline tools["${name}"].version must be a non-empty string: ${toolingBaselinePath}`,
|
|
138
|
+
);
|
|
139
|
+
process.exit(2);
|
|
140
|
+
}
|
|
141
|
+
deps[name] = v;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return deps;
|
|
115
145
|
}
|
|
116
146
|
|
|
117
147
|
function patchEslintConfig(existing) {
|
|
@@ -186,19 +216,15 @@ export function runSyncLint(options) {
|
|
|
186
216
|
typeof scripts[REQUIRED_LINT_SCRIPT_KEY] === 'string'
|
|
187
217
|
? scripts[REQUIRED_LINT_SCRIPT_KEY]
|
|
188
218
|
: null;
|
|
189
|
-
const
|
|
190
|
-
typeof devDependencies['@produck/eslint-rules'] === 'string'
|
|
191
|
-
? devDependencies['@produck/eslint-rules']
|
|
192
|
-
: null;
|
|
193
|
-
|
|
194
|
-
const requiredEslintRulesDependency = getRequiredEslintRulesDevDependency();
|
|
219
|
+
const requiredEslintDevDeps = getRequiredEslintDevDependencies();
|
|
195
220
|
|
|
196
221
|
const eslintConfigPath = path.resolve(cwd, ESLINT_CONFIG_FILE);
|
|
197
222
|
const previousEslintConfig = readFileIfExists(eslintConfigPath);
|
|
198
223
|
|
|
199
224
|
const matchesRequiredLint = previousLint === REQUIRED_LINT_SCRIPT_VALUE;
|
|
200
|
-
const
|
|
201
|
-
|
|
225
|
+
const matchesRequiredEslintDeps = Object.entries(requiredEslintDevDeps).every(
|
|
226
|
+
([name, version]) => devDependencies[name] === version,
|
|
227
|
+
);
|
|
202
228
|
|
|
203
229
|
let eslintConfigAction = 'unchanged';
|
|
204
230
|
let matchesRequiredEslintConfig = false;
|
|
@@ -223,7 +249,7 @@ export function runSyncLint(options) {
|
|
|
223
249
|
|
|
224
250
|
const requiresUpdate =
|
|
225
251
|
!matchesRequiredLint ||
|
|
226
|
-
!
|
|
252
|
+
!matchesRequiredEslintDeps ||
|
|
227
253
|
!matchesRequiredEslintConfig;
|
|
228
254
|
const hasUnpatchableEslintConfig = eslintConfigAction === 'unpatchable';
|
|
229
255
|
|
|
@@ -231,7 +257,9 @@ export function runSyncLint(options) {
|
|
|
231
257
|
scripts[REQUIRED_LINT_SCRIPT_KEY] = REQUIRED_LINT_SCRIPT_VALUE;
|
|
232
258
|
pkg.scripts = scripts;
|
|
233
259
|
|
|
234
|
-
|
|
260
|
+
for (const [name, version] of Object.entries(requiredEslintDevDeps)) {
|
|
261
|
+
devDependencies[name] = version;
|
|
262
|
+
}
|
|
235
263
|
pkg.devDependencies = devDependencies;
|
|
236
264
|
|
|
237
265
|
fs.writeFileSync(
|
|
@@ -257,22 +285,22 @@ export function runSyncLint(options) {
|
|
|
257
285
|
required: {
|
|
258
286
|
lintScriptKey: REQUIRED_LINT_SCRIPT_KEY,
|
|
259
287
|
lintScriptValue: REQUIRED_LINT_SCRIPT_VALUE,
|
|
260
|
-
|
|
288
|
+
eslintDevDependencies: requiredEslintDevDeps,
|
|
261
289
|
eslintConfigPath: path.relative(cwd, eslintConfigPath),
|
|
262
290
|
eslintConfigAction,
|
|
263
291
|
},
|
|
264
292
|
status: {
|
|
265
293
|
matchesRequiredLintBefore: matchesRequiredLint,
|
|
266
|
-
|
|
294
|
+
matchesRequiredEslintDepsBefore: matchesRequiredEslintDeps,
|
|
267
295
|
matchesRequiredEslintConfigBefore: matchesRequiredEslintConfig,
|
|
268
296
|
matchesRequiredLintAfter:
|
|
269
297
|
requiresUpdate && mode === 'sync' && !hasUnpatchableEslintConfig
|
|
270
298
|
? true
|
|
271
299
|
: matchesRequiredLint,
|
|
272
|
-
|
|
300
|
+
matchesRequiredEslintDepsAfter:
|
|
273
301
|
requiresUpdate && mode === 'sync' && !hasUnpatchableEslintConfig
|
|
274
302
|
? true
|
|
275
|
-
:
|
|
303
|
+
: matchesRequiredEslintDeps,
|
|
276
304
|
matchesRequiredEslintConfigAfter:
|
|
277
305
|
requiresUpdate && mode === 'sync' && !hasUnpatchableEslintConfig
|
|
278
306
|
? true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@produck/agent-toolkit",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Central CLI toolkit for organization AI execution workflows",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"@produck/eslint-rules": "^0.3.6",
|
|
33
33
|
"c8": "11.0.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "053cbbf05ab8e6713cd6144766b9e734443c35c9"
|
|
36
36
|
}
|