@neon-pixels/scripts 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -3
- package/dist/allowlist-B_zgqKrH.js +151 -0
- package/dist/audit-gate.js +50 -175
- package/dist/check-absent-dependency.js +161 -0
- package/dist/check-migration-drift.js +128 -0
- package/dist/check-migration-snapshots.js +94 -0
- package/dist/{workflow-command-BkYMh3G8.js → client-fLNszLcv.js} +18 -8
- package/dist/options-C_apa01R.js +82 -0
- package/dist/report-lighthouse-failure.js +408 -0
- package/dist/should-deploy.js +16 -10
- package/dist/sync-templates.js +297 -0
- package/dist/verify-netlify-deploy.js +29 -6
- package/dist/workflow-command-Bb1eVLow.js +16 -0
- package/package.json +9 -3
- package/templates/base/.github/dependabot.yml +34 -0
- package/templates/base/.gitleaks.toml +37 -0
- package/templates/base/.husky/post-merge +4 -0
- package/templates/base/.husky/pre-commit +10 -0
- package/templates/base/.husky/pre-push +9 -0
- package/templates/base/.nvmrc +1 -0
- package/templates/base/package-fields.json +5 -0
- package/templates/nuxt/.husky/pre-push +17 -0
- package/templates/vitepress/.github/dependabot.yml +55 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { parseArgs } from "node:util";
|
|
4
|
+
import { r as prefixedConsole, t as describeError } from "./workflow-command-Bb1eVLow.js";
|
|
5
|
+
import { existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
7
|
+
// src/template-sync/diff.ts
|
|
8
|
+
function fillRow(table, before, after, row) {
|
|
9
|
+
for (let column = after.length - 1; column >= 0; column--) table[row][column] = before[row] === after[column] ? table[row + 1][column + 1] + 1 : Math.max(table[row + 1][column], table[row][column + 1]);
|
|
10
|
+
}
|
|
11
|
+
function longestCommonSubsequence(before, after) {
|
|
12
|
+
const table = Array.from({ length: before.length + 1 }, () => new Array(after.length + 1).fill(0));
|
|
13
|
+
for (let row = before.length - 1; row >= 0; row--) fillRow(table, before, after, row);
|
|
14
|
+
return table;
|
|
15
|
+
}
|
|
16
|
+
/** A line diff with `-` for lines only in the repository and `+` for lines only in the template. Unchanged lines are left out. */
|
|
17
|
+
function describeDifference(before, after) {
|
|
18
|
+
const beforeLines = before.split("\n");
|
|
19
|
+
const afterLines = after.split("\n");
|
|
20
|
+
const table = longestCommonSubsequence(beforeLines, afterLines);
|
|
21
|
+
const changes = [];
|
|
22
|
+
let row = 0;
|
|
23
|
+
let column = 0;
|
|
24
|
+
while (row < beforeLines.length || column < afterLines.length) if (row < beforeLines.length && column < afterLines.length && beforeLines[row] === afterLines[column]) {
|
|
25
|
+
row++;
|
|
26
|
+
column++;
|
|
27
|
+
} else if (column >= afterLines.length || row < beforeLines.length && table[row + 1][column] >= table[row][column + 1]) {
|
|
28
|
+
changes.push(`- ${beforeLines[row]}`);
|
|
29
|
+
row++;
|
|
30
|
+
} else {
|
|
31
|
+
changes.push(`+ ${afterLines[column]}`);
|
|
32
|
+
column++;
|
|
33
|
+
}
|
|
34
|
+
return changes;
|
|
35
|
+
}
|
|
36
|
+
// src/template-sync/files.ts
|
|
37
|
+
function isInside(root, target) {
|
|
38
|
+
const path = relative(root, target);
|
|
39
|
+
return path !== "" && !path.startsWith("..") && !isAbsolute(path);
|
|
40
|
+
}
|
|
41
|
+
function deepestExistingAncestor(path) {
|
|
42
|
+
let current = path;
|
|
43
|
+
while (lstatSync(current, { throwIfNoEntry: false }) === void 0) current = dirname(current);
|
|
44
|
+
return current;
|
|
45
|
+
}
|
|
46
|
+
function realpathOrRefuse(existingAncestor, path) {
|
|
47
|
+
try {
|
|
48
|
+
return realpathSync(existingAncestor);
|
|
49
|
+
} catch {
|
|
50
|
+
throw new Error(`Refusing to touch ${path}: it passes through a broken symbolic link.`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Resolves a repository-relative path and throws unless it stays inside the
|
|
55
|
+
* root, following symlinks, so a linked directory cannot lead a write out of
|
|
56
|
+
* the repository.
|
|
57
|
+
*/
|
|
58
|
+
function resolveInsideRoot(root, path) {
|
|
59
|
+
const target = resolve(root, path);
|
|
60
|
+
if (!isInside(resolve(root), target)) throw new Error(`Refusing to touch ${path}: it is outside the repository.`);
|
|
61
|
+
if (lstatSync(target, { throwIfNoEntry: false })?.isSymbolicLink()) throw new Error(`Refusing to touch ${path}: it is a symbolic link.`);
|
|
62
|
+
const existingAncestor = deepestExistingAncestor(target);
|
|
63
|
+
const realTarget = join(realpathOrRefuse(existingAncestor, path), relative(existingAncestor, target));
|
|
64
|
+
if (!isInside(realpathSync(root), realTarget)) throw new Error(`Refusing to touch ${path}: it resolves outside the repository.`);
|
|
65
|
+
return target;
|
|
66
|
+
}
|
|
67
|
+
function readRepositoryFile(root, path) {
|
|
68
|
+
const target = resolveInsideRoot(root, path);
|
|
69
|
+
return existsSync(target) ? readFileSync(target, "utf8") : null;
|
|
70
|
+
}
|
|
71
|
+
function writeRepositoryFile(root, path, text) {
|
|
72
|
+
const target = resolveInsideRoot(root, path);
|
|
73
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
74
|
+
writeFileSync(target, text);
|
|
75
|
+
}
|
|
76
|
+
// src/template-sync/manifest.ts
|
|
77
|
+
const STACKS = [
|
|
78
|
+
"nuxt",
|
|
79
|
+
"vitepress",
|
|
80
|
+
"node"
|
|
81
|
+
];
|
|
82
|
+
/** Template directory every stack falls back to when it has no variant of its own. */
|
|
83
|
+
const BASE_TEMPLATE_DIRECTORY = "base";
|
|
84
|
+
/**
|
|
85
|
+
* The only repository files the sync ever touches, as paths relative to the
|
|
86
|
+
* repository root. A file under `templates/` that is not listed here is never
|
|
87
|
+
* copied.
|
|
88
|
+
*/
|
|
89
|
+
const TEMPLATE_FILES = [
|
|
90
|
+
".nvmrc",
|
|
91
|
+
".gitleaks.toml",
|
|
92
|
+
".github/dependabot.yml",
|
|
93
|
+
".husky/pre-commit",
|
|
94
|
+
".husky/pre-push",
|
|
95
|
+
".husky/post-merge"
|
|
96
|
+
];
|
|
97
|
+
/** The repository's own `package.json`, where only the fields in the template below are synced. */
|
|
98
|
+
const PACKAGE_JSON = "package.json";
|
|
99
|
+
const PACKAGE_FIELDS_TEMPLATE = "package-fields.json";
|
|
100
|
+
function isStack(value) {
|
|
101
|
+
return STACKS.includes(value);
|
|
102
|
+
}
|
|
103
|
+
// src/template-sync/package-fields.ts
|
|
104
|
+
const DEFAULT_INDENT = 2;
|
|
105
|
+
function isObject(value) {
|
|
106
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
107
|
+
}
|
|
108
|
+
function parseObject(text, label) {
|
|
109
|
+
let parsed;
|
|
110
|
+
try {
|
|
111
|
+
parsed = JSON.parse(text);
|
|
112
|
+
} catch {
|
|
113
|
+
throw new Error(`${label} is not valid JSON.`);
|
|
114
|
+
}
|
|
115
|
+
if (!isObject(parsed)) throw new Error(`${label} must hold a JSON object.`);
|
|
116
|
+
return parsed;
|
|
117
|
+
}
|
|
118
|
+
function mergeFields(target, fields) {
|
|
119
|
+
const merged = { ...target };
|
|
120
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
121
|
+
const current = merged[key];
|
|
122
|
+
merged[key] = isObject(value) && isObject(current) ? mergeFields(current, value) : value;
|
|
123
|
+
}
|
|
124
|
+
return merged;
|
|
125
|
+
}
|
|
126
|
+
function detectIndent(text) {
|
|
127
|
+
return /^([ \t]+)"/m.exec(text)?.[1] ?? DEFAULT_INDENT;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Sets the template's fields in a `package.json`, keeping every other field
|
|
131
|
+
* and the key order. When something changes the file is re-serialized with its
|
|
132
|
+
* detected indentation, so hand formatting beyond that (such as inline arrays)
|
|
133
|
+
* is normalized. Returns the text unchanged when the fields already match.
|
|
134
|
+
*/
|
|
135
|
+
function applyPackageFields(packageJsonText, fieldsText) {
|
|
136
|
+
const original = parseObject(packageJsonText, "package.json");
|
|
137
|
+
const merged = mergeFields(original, parseObject(fieldsText, "package fields template"));
|
|
138
|
+
if (JSON.stringify(merged) === JSON.stringify(original)) return packageJsonText;
|
|
139
|
+
const trailingNewline = packageJsonText.endsWith("\n") ? "\n" : "";
|
|
140
|
+
return `${JSON.stringify(merged, null, detectIndent(packageJsonText))}${trailingNewline}`;
|
|
141
|
+
}
|
|
142
|
+
// src/template-sync/markers.ts
|
|
143
|
+
const BEGIN_PATTERN = /^\s*# np-sync:begin ([\w-]+)\s*$/;
|
|
144
|
+
const END_PATTERN = /^\s*# np-sync:end ([\w-]+)\s*$/;
|
|
145
|
+
function findSections(lines, label) {
|
|
146
|
+
const sections = [];
|
|
147
|
+
let openName = null;
|
|
148
|
+
let openLine = 0;
|
|
149
|
+
for (const [index, line] of lines.entries()) {
|
|
150
|
+
const beginName = BEGIN_PATTERN.exec(line)?.[1];
|
|
151
|
+
const endName = END_PATTERN.exec(line)?.[1];
|
|
152
|
+
if (beginName && openName !== null) throw new Error(`${label}: section "${beginName}" starts inside section "${openName}".`);
|
|
153
|
+
if (beginName) {
|
|
154
|
+
openName = beginName;
|
|
155
|
+
openLine = index;
|
|
156
|
+
}
|
|
157
|
+
if (endName && endName !== openName) throw new Error(`${label}: unmatched end marker for "${endName}".`);
|
|
158
|
+
if (endName && openName !== null) {
|
|
159
|
+
sections.push({
|
|
160
|
+
name: openName,
|
|
161
|
+
begin: openLine,
|
|
162
|
+
end: index
|
|
163
|
+
});
|
|
164
|
+
openName = null;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (openName !== null) throw new Error(`${label}: section "${openName}" is never closed.`);
|
|
168
|
+
return sections;
|
|
169
|
+
}
|
|
170
|
+
function assertUniqueNames(sections, label) {
|
|
171
|
+
const seen = /* @__PURE__ */ new Set();
|
|
172
|
+
for (const section of sections) {
|
|
173
|
+
if (seen.has(section.name)) throw new Error(`${label}: section "${section.name}" appears twice.`);
|
|
174
|
+
seen.add(section.name);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function readSections(text, label) {
|
|
178
|
+
const lines = text.split("\n");
|
|
179
|
+
const sections = findSections(lines, label);
|
|
180
|
+
assertUniqueNames(sections, label);
|
|
181
|
+
return new Map(sections.map((section) => [section.name, lines.slice(section.begin + 1, section.end)]));
|
|
182
|
+
}
|
|
183
|
+
function assertNoUnknownSections(kept, templateSections, label) {
|
|
184
|
+
const known = new Set(templateSections.map((section) => section.name));
|
|
185
|
+
for (const [name, lines] of kept) {
|
|
186
|
+
const isEmpty = lines.every((line) => line.trim() === "");
|
|
187
|
+
if (!known.has(name) && !isEmpty) throw new Error(`${label}: section "${name}" is not in the template, so its lines would be dropped.`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Renders a template for a repository. A section between
|
|
192
|
+
* `# np-sync:begin <name>` and `# np-sync:end <name>` keeps the repository's
|
|
193
|
+
* own lines when the existing file has a section of that name; everything else
|
|
194
|
+
* comes from the template. Throws when either side has broken markers, so a
|
|
195
|
+
* repository's own lines are never silently dropped.
|
|
196
|
+
*/
|
|
197
|
+
function preserveSections(template, existing, label) {
|
|
198
|
+
const templateLines = template.split("\n");
|
|
199
|
+
const sections = findSections(templateLines, `template ${label}`);
|
|
200
|
+
assertUniqueNames(sections, `template ${label}`);
|
|
201
|
+
if (existing === null) return template;
|
|
202
|
+
const kept = readSections(existing, label);
|
|
203
|
+
assertNoUnknownSections(kept, sections, label);
|
|
204
|
+
const output = [];
|
|
205
|
+
let cursor = 0;
|
|
206
|
+
for (const section of sections) {
|
|
207
|
+
const keptLines = kept.get(section.name);
|
|
208
|
+
output.push(...templateLines.slice(cursor, section.begin + 1));
|
|
209
|
+
output.push(...keptLines ?? templateLines.slice(section.begin + 1, section.end));
|
|
210
|
+
cursor = section.end;
|
|
211
|
+
}
|
|
212
|
+
output.push(...templateLines.slice(cursor));
|
|
213
|
+
return output.join("\n");
|
|
214
|
+
}
|
|
215
|
+
// src/template-sync/plan.ts
|
|
216
|
+
/** A stack's own variant wins; otherwise the base template is used. */
|
|
217
|
+
function readTemplate(templatesRoot, stack, path) {
|
|
218
|
+
for (const directory of [stack, BASE_TEMPLATE_DIRECTORY]) {
|
|
219
|
+
const candidate = join(templatesRoot, directory, path);
|
|
220
|
+
if (existsSync(candidate)) return readFileSync(candidate, "utf8");
|
|
221
|
+
}
|
|
222
|
+
throw new Error(`No template for ${path} (stack ${stack}).`);
|
|
223
|
+
}
|
|
224
|
+
function planCopiedFile(root, templatesRoot, stack, path) {
|
|
225
|
+
const before = readRepositoryFile(root, path);
|
|
226
|
+
return {
|
|
227
|
+
path,
|
|
228
|
+
before,
|
|
229
|
+
after: preserveSections(readTemplate(templatesRoot, stack, path), before, path)
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function planPackageJson(root, templatesRoot, stack) {
|
|
233
|
+
const before = readRepositoryFile(root, PACKAGE_JSON);
|
|
234
|
+
if (before === null) throw new Error(`${PACKAGE_JSON} not found in ${root}. Run this from the repository root.`);
|
|
235
|
+
const fields = readTemplate(templatesRoot, stack, PACKAGE_FIELDS_TEMPLATE);
|
|
236
|
+
return {
|
|
237
|
+
path: PACKAGE_JSON,
|
|
238
|
+
before,
|
|
239
|
+
after: applyPackageFields(before, fields)
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
/** Every manifest file, in manifest order, whether or not it differs. */
|
|
243
|
+
function planSync(root, templatesRoot, stack) {
|
|
244
|
+
return [...TEMPLATE_FILES.map((path) => planCopiedFile(root, templatesRoot, stack, path)), planPackageJson(root, templatesRoot, stack)];
|
|
245
|
+
}
|
|
246
|
+
// src/template-sync/run.ts
|
|
247
|
+
const output = prefixedConsole("np-sync-templates");
|
|
248
|
+
function readStack(value) {
|
|
249
|
+
if (value === void 0 || !isStack(value)) throw new Error(`--stack is required and must be one of: ${STACKS.join(", ")}.`);
|
|
250
|
+
return value;
|
|
251
|
+
}
|
|
252
|
+
function isChanged(change) {
|
|
253
|
+
return change.before !== change.after;
|
|
254
|
+
}
|
|
255
|
+
function reportDifferences(changes) {
|
|
256
|
+
for (const change of changes) {
|
|
257
|
+
const lines = change.before === null ? ["(file is missing)"] : describeDifference(change.before, change.after);
|
|
258
|
+
output.error(`${change.path} differs from the template:`);
|
|
259
|
+
console.error(lines.join("\n"));
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function writeChanges(root, changes) {
|
|
263
|
+
for (const change of changes) {
|
|
264
|
+
writeRepositoryFile(root, change.path, change.after);
|
|
265
|
+
output.log(`${change.before === null ? "created" : "updated"} ${change.path}`);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
/** Copies the stack's templates into the repository, or with `--check` only reports drift. Returns the exit code. */
|
|
269
|
+
function runSyncTemplates(argv, environment) {
|
|
270
|
+
try {
|
|
271
|
+
const { values } = parseArgs({
|
|
272
|
+
args: argv,
|
|
273
|
+
options: {
|
|
274
|
+
stack: { type: "string" },
|
|
275
|
+
check: { type: "boolean" }
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
const stack = readStack(values.stack);
|
|
279
|
+
const changes = planSync(environment.root, environment.templatesRoot, stack).filter(isChanged);
|
|
280
|
+
if (values.check) {
|
|
281
|
+
reportDifferences(changes);
|
|
282
|
+
return changes.length === 0 ? 0 : 1;
|
|
283
|
+
}
|
|
284
|
+
writeChanges(environment.root, changes);
|
|
285
|
+
output.log(changes.length === 0 ? "already up to date." : `synced ${changes.length} file(s).`);
|
|
286
|
+
return 0;
|
|
287
|
+
} catch (error) {
|
|
288
|
+
output.error(describeError(error));
|
|
289
|
+
return 1;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
// src/sync-templates.ts
|
|
293
|
+
process.exitCode = runSyncTemplates(process.argv.slice(2), {
|
|
294
|
+
root: process.cwd(),
|
|
295
|
+
templatesRoot: fileURLToPath(new URL("../templates", import.meta.url))
|
|
296
|
+
});
|
|
297
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { n as createNetlifyClient, t as NetlifyFatalError } from "./client-fLNszLcv.js";
|
|
3
3
|
import { parseArgs } from "node:util";
|
|
4
|
+
import { n as escapeWorkflowCommand, t as describeError } from "./workflow-command-Bb1eVLow.js";
|
|
4
5
|
// src/verify-deploy/evaluate.ts
|
|
5
6
|
const SUCCESS_STATES = /* @__PURE__ */ new Set(["ready"]);
|
|
6
7
|
const FAILURE_STATES = /* @__PURE__ */ new Set([
|
|
@@ -130,9 +131,16 @@ async function fetchTargetDeploy(request, client) {
|
|
|
130
131
|
if (target.kind === "deploy-id") return client.getDeploy(target.deployId);
|
|
131
132
|
return findTriggeredDeploy(await client.listProductionDeploys(), target);
|
|
132
133
|
}
|
|
133
|
-
function
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
async function resolveSiteId(request, deploy, client) {
|
|
135
|
+
return deploy.siteId === request.siteId ? request.siteId : client.getSiteId();
|
|
136
|
+
}
|
|
137
|
+
async function describeOwnership(request, deploy, client) {
|
|
138
|
+
if (request.target.kind !== "deploy-id") return null;
|
|
139
|
+
return describeOwnershipProblem(deploy, await resolveSiteId(request, deploy, client));
|
|
140
|
+
}
|
|
141
|
+
async function judgeDeploy(request, deploy, environment) {
|
|
142
|
+
environment.log(`Deploy ${deploy.id}: ${deploy.state}`);
|
|
143
|
+
const ownershipProblem = await describeOwnership(request, deploy, environment.client);
|
|
136
144
|
if (ownershipProblem !== null) return { done: {
|
|
137
145
|
ok: false,
|
|
138
146
|
message: ownershipProblem
|
|
@@ -156,7 +164,7 @@ async function pollOnce(request, environment) {
|
|
|
156
164
|
environment.log(`No Netlify deploy found: ${observation}`);
|
|
157
165
|
return { observation };
|
|
158
166
|
}
|
|
159
|
-
return judgeDeploy(request, deploy, environment
|
|
167
|
+
return await judgeDeploy(request, deploy, environment);
|
|
160
168
|
} catch (error) {
|
|
161
169
|
const reason = describeError(error);
|
|
162
170
|
if (error instanceof NetlifyFatalError) return { done: {
|
|
@@ -173,7 +181,22 @@ function timeoutResult(request, lastObservation) {
|
|
|
173
181
|
message: `Timed out after ${Math.round(request.timeoutMs / MILLISECONDS_PER_SECOND)} seconds waiting for the Netlify deploy ${describeTarget(request.target)}; last observed ${lastObservation}.`
|
|
174
182
|
};
|
|
175
183
|
}
|
|
176
|
-
|
|
184
|
+
function rememberSiteLookup(client) {
|
|
185
|
+
let siteId = null;
|
|
186
|
+
return {
|
|
187
|
+
listProductionDeploys: () => client.listProductionDeploys(),
|
|
188
|
+
getDeploy: (deployId) => client.getDeploy(deployId),
|
|
189
|
+
async getSiteId() {
|
|
190
|
+
siteId ??= await client.getSiteId();
|
|
191
|
+
return siteId;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
async function verifyDeploy(request, pollEnvironment) {
|
|
196
|
+
const environment = {
|
|
197
|
+
...pollEnvironment,
|
|
198
|
+
client: rememberSiteLookup(pollEnvironment.client)
|
|
199
|
+
};
|
|
177
200
|
const deadline = environment.now() + request.timeoutMs;
|
|
178
201
|
while (true) {
|
|
179
202
|
const step = await pollOnce(request, environment);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/workflow-command.ts
|
|
2
|
+
function describeError(error) {
|
|
3
|
+
return error instanceof Error ? error.message : String(error);
|
|
4
|
+
}
|
|
5
|
+
function escapeWorkflowCommand(text) {
|
|
6
|
+
return text.replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A");
|
|
7
|
+
}
|
|
8
|
+
/** Console output prefixed with the command name, the same way for every bin. */
|
|
9
|
+
function prefixedConsole(commandName) {
|
|
10
|
+
return {
|
|
11
|
+
log: (message) => console.log(`${commandName}: ${message}`),
|
|
12
|
+
warn: (message) => console.warn(`${commandName}: ${message}`),
|
|
13
|
+
error: (message) => console.error(`${commandName}: ${message}`)
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export { escapeWorkflowCommand as n, prefixedConsole as r, describeError as t };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neon-pixels/scripts",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "CI and deploy scripts for Neon Pixels projects: dependency audit gate, GitHub Actions pinning check,
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "CI and deploy scripts for Neon Pixels projects: dependency audit gate, a build-output check that a dependency is absent, GitHub Actions pinning check, migration bookkeeping checks, Lighthouse failure reporting, Netlify production deploy checks, and a sync of hooks, Dependabot, gitleaks, and Node version templates.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
@@ -11,15 +11,21 @@
|
|
|
11
11
|
},
|
|
12
12
|
"bin": {
|
|
13
13
|
"np-audit-gate": "./dist/audit-gate.js",
|
|
14
|
+
"np-check-absent-dependency": "./dist/check-absent-dependency.js",
|
|
14
15
|
"np-check-action-pinning": "./dist/check-action-pinning.js",
|
|
16
|
+
"np-check-migration-drift": "./dist/check-migration-drift.js",
|
|
17
|
+
"np-check-migration-snapshots": "./dist/check-migration-snapshots.js",
|
|
18
|
+
"np-report-lighthouse-failure": "./dist/report-lighthouse-failure.js",
|
|
15
19
|
"np-should-deploy": "./dist/should-deploy.js",
|
|
20
|
+
"np-sync-templates": "./dist/sync-templates.js",
|
|
16
21
|
"np-verify-netlify-deploy": "./dist/verify-netlify-deploy.js"
|
|
17
22
|
},
|
|
18
23
|
"exports": {
|
|
19
24
|
"./package.json": "./package.json"
|
|
20
25
|
},
|
|
21
26
|
"files": [
|
|
22
|
-
"dist"
|
|
27
|
+
"dist",
|
|
28
|
+
"templates"
|
|
23
29
|
],
|
|
24
30
|
"publishConfig": {
|
|
25
31
|
"access": "public"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
# No target-branch override: updates go to the default branch, which also keeps
|
|
3
|
+
# Dependabot security update PRs enabled.
|
|
4
|
+
updates:
|
|
5
|
+
- package-ecosystem: npm
|
|
6
|
+
directory: "/"
|
|
7
|
+
assignees:
|
|
8
|
+
- grimicorn
|
|
9
|
+
schedule:
|
|
10
|
+
interval: weekly
|
|
11
|
+
groups:
|
|
12
|
+
# Listed first on purpose: Dependabot assigns a dependency to the first
|
|
13
|
+
# group that matches it, so the shared packages must be claimed before
|
|
14
|
+
# `minor-and-patch` can swallow their minor and patch bumps.
|
|
15
|
+
neon-pixels:
|
|
16
|
+
patterns:
|
|
17
|
+
- "@neon-pixels/*"
|
|
18
|
+
# Collapse all minor and patch bumps into a single PR to reduce churn.
|
|
19
|
+
minor-and-patch:
|
|
20
|
+
update-types:
|
|
21
|
+
- minor
|
|
22
|
+
- patch
|
|
23
|
+
- package-ecosystem: github-actions
|
|
24
|
+
directory: "/"
|
|
25
|
+
assignees:
|
|
26
|
+
- grimicorn
|
|
27
|
+
schedule:
|
|
28
|
+
interval: weekly
|
|
29
|
+
groups:
|
|
30
|
+
# Keep the SHA-pinned workflow actions current in a single PR.
|
|
31
|
+
actions:
|
|
32
|
+
update-types:
|
|
33
|
+
- minor
|
|
34
|
+
- patch
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Gitleaks configuration. Extends the default ruleset and adds rules for the
|
|
2
|
+
# secret shapes the defaults miss. Anything between the np-sync markers is kept
|
|
3
|
+
# when templates are synced; everything else is overwritten.
|
|
4
|
+
# Docs: https://github.com/gitleaks/gitleaks#configuration
|
|
5
|
+
|
|
6
|
+
[extend]
|
|
7
|
+
useDefault = true
|
|
8
|
+
|
|
9
|
+
[[rules]]
|
|
10
|
+
id = "clerk-secret-key"
|
|
11
|
+
description = "Clerk secret key (sk_live_ / sk_test_)"
|
|
12
|
+
# Publishable keys (pk_live_/pk_test_) are public by design and intentionally excluded.
|
|
13
|
+
regex = '''sk_(?:live|test)_[A-Za-z0-9_-]{16,}'''
|
|
14
|
+
keywords = ["sk_live_", "sk_test_"]
|
|
15
|
+
|
|
16
|
+
[[rules]]
|
|
17
|
+
id = "postgres-connection-string-with-credentials"
|
|
18
|
+
description = "Postgres connection string containing user:password credentials"
|
|
19
|
+
regex = '''postgres(?:ql)?:\/\/[^\s:@\/]+:[^\s:@\/]+@[^\s\/]+'''
|
|
20
|
+
keywords = ["postgres://", "postgresql://"]
|
|
21
|
+
|
|
22
|
+
# np-sync:begin extra-rules
|
|
23
|
+
# np-sync:end extra-rules
|
|
24
|
+
|
|
25
|
+
[allowlist]
|
|
26
|
+
description = "Allow documented placeholders and test fixtures"
|
|
27
|
+
# Example and sample env files hold documented placeholders, and fixture
|
|
28
|
+
# directories hold synthetic secrets. Test source files are still scanned.
|
|
29
|
+
paths = [
|
|
30
|
+
'''(^|/)\.env\.(example|sample)$''',
|
|
31
|
+
'''\.example$''',
|
|
32
|
+
'''(^|/)(fixtures?|__fixtures__|test-fixtures?)/''',
|
|
33
|
+
]
|
|
34
|
+
# Add reviewed fingerprints or regexes for this repository here, for example
|
|
35
|
+
# `commits = [...]` or `regexes = [...]`. Do not repeat the `paths` key.
|
|
36
|
+
# np-sync:begin allowlist
|
|
37
|
+
# np-sync:end allowlist
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# np-sync:begin repo-specific
|
|
2
|
+
# np-sync:end repo-specific
|
|
3
|
+
|
|
4
|
+
if ! command -v gitleaks >/dev/null 2>&1; then
|
|
5
|
+
echo "WARNING: gitleaks is not installed, so the pre-commit secret scan was SKIPPED." >&2
|
|
6
|
+
echo "Install it to enable the local scan (e.g. 'brew install gitleaks'); see https://github.com/gitleaks/gitleaks#installing" >&2
|
|
7
|
+
exit 0
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
gitleaks git --staged --redact --config .gitleaks.toml
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
26.13.1
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Mirrors the `ci` job in .github/workflows/ci.yml. Keep the two in sync.
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
# np-sync:begin repo-specific
|
|
5
|
+
# np-sync:end repo-specific
|
|
6
|
+
|
|
7
|
+
if git rev-parse --verify --quiet "refs/remotes/origin/main^{commit}" >/dev/null; then
|
|
8
|
+
lint_script="lint:ci"
|
|
9
|
+
else
|
|
10
|
+
echo "origin/main not found - falling back to full lint instead of lint:ci." >&2
|
|
11
|
+
lint_script="lint"
|
|
12
|
+
fi
|
|
13
|
+
|
|
14
|
+
npm run "$lint_script"
|
|
15
|
+
npx nuxt prepare
|
|
16
|
+
npm run typecheck
|
|
17
|
+
npm run test:ci
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
# No target-branch override: updates go to the default branch, which also keeps
|
|
3
|
+
# Dependabot security update PRs enabled.
|
|
4
|
+
updates:
|
|
5
|
+
- package-ecosystem: npm
|
|
6
|
+
directory: "/"
|
|
7
|
+
assignees:
|
|
8
|
+
- grimicorn
|
|
9
|
+
schedule:
|
|
10
|
+
interval: weekly
|
|
11
|
+
groups:
|
|
12
|
+
# Listed first on purpose: Dependabot assigns a dependency to the first
|
|
13
|
+
# group that matches it, so the shared packages must be claimed before
|
|
14
|
+
# `minor-and-patch` can swallow their minor and patch bumps.
|
|
15
|
+
neon-pixels:
|
|
16
|
+
patterns:
|
|
17
|
+
- "@neon-pixels/*"
|
|
18
|
+
# Kept ahead of `vite-vitepress` so minor and patch bumps, vite and
|
|
19
|
+
# vitepress included, land in one weekly PR.
|
|
20
|
+
minor-and-patch:
|
|
21
|
+
update-types:
|
|
22
|
+
- minor
|
|
23
|
+
- patch
|
|
24
|
+
# vite, vitepress, and the tools that peer on vite move together. A major
|
|
25
|
+
# bump to any of them falls through the group above into this one, so it
|
|
26
|
+
# ships in one PR instead of splitting across stale peer ranges.
|
|
27
|
+
vite-vitepress:
|
|
28
|
+
patterns:
|
|
29
|
+
- vite
|
|
30
|
+
- vitepress
|
|
31
|
+
- "@tailwindcss/vite"
|
|
32
|
+
- "@vitejs/plugin-vue"
|
|
33
|
+
- vitest
|
|
34
|
+
# A group's patterns only apply to scheduled updates unless
|
|
35
|
+
# `applies-to: security-updates` is set, so security bumps need their own.
|
|
36
|
+
vite-vitepress-security:
|
|
37
|
+
applies-to: security-updates
|
|
38
|
+
patterns:
|
|
39
|
+
- vite
|
|
40
|
+
- vitepress
|
|
41
|
+
- "@tailwindcss/vite"
|
|
42
|
+
- "@vitejs/plugin-vue"
|
|
43
|
+
- vitest
|
|
44
|
+
- package-ecosystem: github-actions
|
|
45
|
+
directory: "/"
|
|
46
|
+
assignees:
|
|
47
|
+
- grimicorn
|
|
48
|
+
schedule:
|
|
49
|
+
interval: weekly
|
|
50
|
+
groups:
|
|
51
|
+
# Keep the SHA-pinned workflow actions current in a single PR.
|
|
52
|
+
actions:
|
|
53
|
+
update-types:
|
|
54
|
+
- minor
|
|
55
|
+
- patch
|