@featherk/icons 0.15.8 → 0.16.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 +15 -3
- package/dist/docs-manifest.d.ts +1 -0
- package/dist/docs-manifest.js +7 -5
- package/dist/fontawesome/build.cjs +1 -2
- package/dist/fontawesome/build.d.ts +1 -1
- package/dist/fontawesome/build.mjs +2 -3
- package/dist/fontawesome/catalog.cjs +0 -13
- package/dist/fontawesome/catalog.d.ts +0 -8
- package/dist/fontawesome/catalog.mjs +0 -13
- package/dist/fontawesome/chunks/{generate-BBurrhLv.cjs → generate-B_FxftR7.cjs} +12 -1
- package/dist/fontawesome/chunks/{generate-Zq9q2YZD.mjs → generate-DF9R65sV.mjs} +13 -2
- package/dist/fontawesome/chunks/manifest-CSRIDvaR.mjs +56 -0
- package/dist/fontawesome/chunks/manifest-Yjw62jxG.cjs +55 -0
- package/dist/fontawesome/cli.cjs +23 -26
- package/dist/fontawesome/cli.mjs +23 -26
- package/dist/fontawesome/generate.d.ts +7 -0
- package/dist/fontawesome/manifest.d.ts +36 -0
- package/dist/fontawesome/setup.cjs +185 -180
- package/dist/fontawesome/setup.d.ts +2 -2
- package/dist/fontawesome/setup.mjs +186 -181
- package/dist/fontawesome/vite.cjs +64 -28
- package/dist/fontawesome/vite.d.ts +26 -5
- package/dist/fontawesome/vite.mjs +65 -29
- package/docs/ICONS.md +1 -1
- package/docs/fontawesome/CreateFontAwesomeManifest.md +1 -1
- package/docs/fontawesome/FontAwesome.md +48 -44
- package/docs/fontawesome/FontAwesomeCLI.md +14 -19
- package/docs/fontawesome/FontAwesomeDeveloperSetup.md +134 -0
- package/docs/fontawesome/LICENSING.md +107 -66
- package/package.json +1 -1
- package/dist/fontawesome/chunks/manifest-BB3q10t1.mjs +0 -20
- package/dist/fontawesome/chunks/manifest-C15Xa22L.cjs +0 -19
|
@@ -6,7 +6,7 @@ const node_path = require("node:path");
|
|
|
6
6
|
const node_readline = require("node:readline");
|
|
7
7
|
const node_util = require("node:util");
|
|
8
8
|
const fontawesome_catalog = require("./catalog.cjs");
|
|
9
|
-
const manifest = require("./chunks/manifest-
|
|
9
|
+
const manifest = require("./chunks/manifest-Yjw62jxG.cjs");
|
|
10
10
|
const tokenVariable = "FONTAWESOME_PACKAGE_TOKEN";
|
|
11
11
|
const tokenPlaceholder = `\${${tokenVariable}}`;
|
|
12
12
|
const registry = "https://npm.fontawesome.com/";
|
|
@@ -25,30 +25,35 @@ const workspaceVariables = [
|
|
|
25
25
|
"NPM_CONFIG_WORKSPACES"
|
|
26
26
|
];
|
|
27
27
|
const usage = `Usage:
|
|
28
|
-
featherk-fontawesome-setup
|
|
29
|
-
featherk-fontawesome-setup
|
|
30
|
-
featherk-fontawesome-setup --source-root <dir> --init (--manifest <icons.json> | --keys <a,b>) [--force]
|
|
28
|
+
featherk-fontawesome-setup --manifest <icons.json> [--free-only | --pro-in-app]
|
|
29
|
+
featherk-fontawesome-setup
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
only) and installs exact pins for all selected keys as devDependencies.
|
|
35
|
-
Commit .npmrc, package.json, and package-lock.json. Later installs, including
|
|
36
|
-
CI, give ${tokenVariable} only to "npm ci --ignore-scripts", then run any
|
|
37
|
-
needed install scripts (npm rebuild for dependencies, plus the app's own) and
|
|
38
|
-
builds without it. Do not export the token persistently.
|
|
31
|
+
Run from the application root. The manifest contains
|
|
32
|
+
{ "free": [keys], "pro": [keys] }, the same file the Vite plugin reads.
|
|
39
33
|
|
|
40
|
-
--
|
|
34
|
+
--manifest (default): installs exact Free pins into the app's devDependencies
|
|
35
|
+
from public npm, and writes exact Pro pins into an isolated private source
|
|
36
|
+
project, ${manifest.fontAwesomeProSourcesDir}/, then installs it with the token. The
|
|
37
|
+
app's own install never needs the token. Rerun after changing the manifest.
|
|
38
|
+
Commit package.json, package-lock.json, and ${manifest.fontAwesomeProSourcesDir}/
|
|
39
|
+
(its node_modules is ignored).
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
No arguments: installs ${manifest.fontAwesomeProSourcesDir}/ from its committed
|
|
42
|
+
lockfile with the token, for CI and fresh clones. Run it after the app's own
|
|
43
|
+
"npm ci".
|
|
44
|
+
|
|
45
|
+
--free-only: Free keys only from public npm. No token, no source project.
|
|
46
|
+
|
|
47
|
+
--pro-in-app: installs Free and Pro pins into the app's own devDependencies
|
|
48
|
+
and routes @fortawesome to the Pro registry in the app's .npmrc (token
|
|
49
|
+
placeholder only). Every install of the app, including CI, then needs the
|
|
50
|
+
token for "npm ci --ignore-scripts". Use only when the isolated project is not
|
|
51
|
+
an option.
|
|
48
52
|
|
|
49
53
|
The token comes from ${tokenVariable} or a hidden prompt in an interactive
|
|
50
|
-
terminal.
|
|
51
|
-
(CI, TEAMCITY_VERSION, or GITHUB_ACTIONS is set)
|
|
54
|
+
terminal. --manifest setup changes package.json and is refused in CI
|
|
55
|
+
(CI, TEAMCITY_VERSION, or GITHUB_ACTIONS is set). Do not export the token
|
|
56
|
+
persistently.`;
|
|
52
57
|
function promptForTerminalToken() {
|
|
53
58
|
const input = process.stdin;
|
|
54
59
|
if (!input.isTTY || typeof input.setRawMode !== "function") {
|
|
@@ -127,19 +132,13 @@ function requireNpm(context) {
|
|
|
127
132
|
return npmCli;
|
|
128
133
|
}
|
|
129
134
|
async function readKeys(values, context) {
|
|
130
|
-
if (values.keys && values.manifest) {
|
|
131
|
-
throw new Error("Provide either --keys or --manifest, not both.");
|
|
132
|
-
}
|
|
133
|
-
if (values.keys) {
|
|
134
|
-
return values.keys.split(",").map((key) => key.trim()).filter(Boolean);
|
|
135
|
-
}
|
|
136
135
|
if (!values.manifest) {
|
|
137
|
-
throw new Error("Provide --manifest
|
|
136
|
+
throw new Error("Provide --manifest. Use --help for usage.");
|
|
138
137
|
}
|
|
139
|
-
const
|
|
138
|
+
const manifest$1 = await manifest.readFontAwesomeManifest(
|
|
140
139
|
node_path.resolve(context.cwd, values.manifest)
|
|
141
140
|
);
|
|
142
|
-
return
|
|
141
|
+
return manifest.fontAwesomeManifestKeys(manifest$1);
|
|
143
142
|
}
|
|
144
143
|
function resolvePins(keys) {
|
|
145
144
|
const tiers = new Map(
|
|
@@ -194,54 +193,11 @@ function checkNpmrc(config, file) {
|
|
|
194
193
|
}
|
|
195
194
|
return { fontAwesomeRegistry, hasAuth };
|
|
196
195
|
}
|
|
197
|
-
|
|
198
|
-
const { log } = context;
|
|
199
|
-
if (context.isCi) {
|
|
200
|
-
throw new Error(
|
|
201
|
-
`App-root setup changes package.json and is a local, one-time step. In CI, give ${tokenVariable} only to "npm ci --ignore-scripts", then run needed install scripts and the build without it.`
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
const appRoot = context.cwd;
|
|
205
|
-
if (!node_fs.existsSync(node_path.resolve(appRoot, "package.json"))) {
|
|
206
|
-
throw new Error(
|
|
207
|
-
"Run this command from the application root (package.json not found)."
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
const freeOnly = Boolean(values["free-only"]);
|
|
211
|
-
const pins = resolvePins(await readKeys(values, context));
|
|
212
|
-
const proPins = [...pins.values()].filter((pin) => pin.tier === "pro");
|
|
213
|
-
if (freeOnly && proPins.length) {
|
|
214
|
-
throw new Error(
|
|
215
|
-
`--free-only cannot install Pro keys: ${proPins.map((pin) => pin.key).join(", ")}.`
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
if (!pins.size) {
|
|
219
|
-
throw new Error("No Font Awesome keys selected.");
|
|
220
|
-
}
|
|
221
|
-
const npmrcPath = node_path.resolve(appRoot, ".npmrc");
|
|
222
|
-
const config = node_fs.existsSync(npmrcPath) ? node_fs.readFileSync(npmrcPath, "utf8") : "";
|
|
223
|
-
const { fontAwesomeRegistry, hasAuth } = checkNpmrc(config, ".npmrc");
|
|
224
|
-
if (freeOnly && fontAwesomeRegistry) {
|
|
225
|
-
throw new Error(
|
|
226
|
-
`.npmrc routes @fortawesome to ${fontAwesomeRegistry}, so this app is set up for Pro. Run without --free-only.`
|
|
227
|
-
);
|
|
228
|
-
}
|
|
196
|
+
function installIntoApp(pins, pro, token, context) {
|
|
229
197
|
const npmCli = requireNpm(context);
|
|
230
198
|
const environment = { ...context.env };
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
const missing = [];
|
|
234
|
-
if (!fontAwesomeRegistry) missing.push(npmrcLines[0], npmrcLines[1]);
|
|
235
|
-
if (!hasAuth) missing.push(npmrcLines[2], npmrcLines[3]);
|
|
236
|
-
if (missing.length) {
|
|
237
|
-
const separator = config && !config.endsWith("\n") ? "\n" : "";
|
|
238
|
-
node_fs.writeFileSync(npmrcPath, `${config}${separator}${missing.join("\n")}
|
|
239
|
-
`);
|
|
240
|
-
log(
|
|
241
|
-
`${config ? "Updated" : "Created"} .npmrc with the Font Awesome registry and token placeholder.`
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
199
|
+
delete environment[tokenVariable];
|
|
200
|
+
if (pro && token) environment[tokenVariable] = token;
|
|
245
201
|
const specs = [...pins].map(([name, pin]) => `${name}@${pin.spec}`);
|
|
246
202
|
const status = context.runNpm({
|
|
247
203
|
npmCli,
|
|
@@ -252,27 +208,18 @@ async function setupAppRoot(values, context) {
|
|
|
252
208
|
"--ignore-scripts",
|
|
253
209
|
"--no-audit",
|
|
254
210
|
"--no-fund",
|
|
255
|
-
...
|
|
211
|
+
...pro ? [pinRegistry] : [],
|
|
256
212
|
...specs
|
|
257
213
|
],
|
|
258
|
-
cwd:
|
|
214
|
+
cwd: context.cwd,
|
|
259
215
|
env: environment
|
|
260
216
|
});
|
|
261
|
-
if (status
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
"Lifecycle scripts were skipped. If needed, run npm rebuild for dependency scripts and the app's own scripts (e.g. npm run prepare --if-present)."
|
|
265
|
-
);
|
|
266
|
-
if (freeOnly) {
|
|
267
|
-
log(
|
|
268
|
-
"Next: commit package.json and package-lock.json. Keep the Vite plugin's allowPro unset (Free only); no CI token is needed."
|
|
269
|
-
);
|
|
270
|
-
} else {
|
|
271
|
-
log(
|
|
272
|
-
`Next: commit .npmrc, package.json, and package-lock.json. Set allowPro: true in the Vite plugin (no sourceRoot). Later installs, including CI, give ${tokenVariable} only to "npm ci --ignore-scripts"; run needed install scripts and builds without it. See LICENSING.md for the TeamCity setup.`
|
|
217
|
+
if (status === 0) {
|
|
218
|
+
context.log(
|
|
219
|
+
`Installed ${specs.length} Font Awesome package(s) into the app: ${specs.join(" ")}`
|
|
273
220
|
);
|
|
274
221
|
}
|
|
275
|
-
return
|
|
222
|
+
return status;
|
|
276
223
|
}
|
|
277
224
|
function readDependencies(packageJsonPath) {
|
|
278
225
|
try {
|
|
@@ -286,109 +233,61 @@ function readDependencies(packageJsonPath) {
|
|
|
286
233
|
return void 0;
|
|
287
234
|
}
|
|
288
235
|
}
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
throw new Error(
|
|
293
|
-
"--init is a local, one-time step. Commit the scaffolded source project instead of generating it in CI."
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
const pins = resolvePins(await readKeys(values, context));
|
|
297
|
-
const dependencies = {};
|
|
298
|
-
const skipped = [];
|
|
299
|
-
for (const [name, pin] of pins) {
|
|
300
|
-
if (pin.tier === "pro") dependencies[name] = pin.spec;
|
|
301
|
-
else skipped.push(pin.key);
|
|
302
|
-
}
|
|
303
|
-
if (!Object.keys(dependencies).length) {
|
|
304
|
-
throw new Error(
|
|
305
|
-
"No Pro keys selected. Free packages belong in the application's own devDependencies."
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
const sortedDependencies = Object.fromEntries(
|
|
309
|
-
Object.entries(dependencies).sort()
|
|
236
|
+
function writeSourceProject(sourceRoot, proPins, context) {
|
|
237
|
+
const dependencies = Object.fromEntries(
|
|
238
|
+
[...proPins].map(([name, pin]) => [name, pin.spec]).sort()
|
|
310
239
|
);
|
|
240
|
+
const created = !node_fs.existsSync(node_path.resolve(sourceRoot, "package.json"));
|
|
241
|
+
const lockfilePath = node_path.resolve(sourceRoot, "package-lock.json");
|
|
242
|
+
const removeStaleLockfile = node_fs.existsSync(lockfilePath) && readDependencies(node_path.resolve(sourceRoot, "package.json")) !== JSON.stringify(dependencies);
|
|
311
243
|
const files = {
|
|
312
244
|
".npmrc": `${npmrcLines.join("\n")}
|
|
313
245
|
`,
|
|
314
246
|
".gitignore": "node_modules/\n",
|
|
315
247
|
"package.json": `${JSON.stringify(
|
|
316
248
|
{
|
|
317
|
-
name:
|
|
249
|
+
name: manifest.fontAwesomeProSourcesDir,
|
|
318
250
|
version: "0.0.0",
|
|
319
251
|
private: true,
|
|
320
|
-
dependencies
|
|
252
|
+
dependencies
|
|
321
253
|
},
|
|
322
254
|
null,
|
|
323
255
|
2
|
|
324
256
|
)}
|
|
325
257
|
`
|
|
326
258
|
};
|
|
327
|
-
const existing = Object.keys(files).filter(
|
|
328
|
-
(name) => node_fs.existsSync(node_path.resolve(sourceRoot, name))
|
|
329
|
-
);
|
|
330
|
-
if (existing.length && !values.force) {
|
|
331
|
-
throw new Error(
|
|
332
|
-
`${display(sourceRoot)} already contains ${existing.join(", ")}. Use --force to overwrite.`
|
|
333
|
-
);
|
|
334
|
-
}
|
|
335
|
-
const lockfilePath = node_path.resolve(sourceRoot, "package-lock.json");
|
|
336
|
-
const removeStaleLockfile = node_fs.existsSync(lockfilePath) && readDependencies(node_path.resolve(sourceRoot, "package.json")) !== JSON.stringify(sortedDependencies);
|
|
337
259
|
node_fs.mkdirSync(sourceRoot, { recursive: true });
|
|
338
260
|
for (const [name, content] of Object.entries(files)) {
|
|
339
261
|
node_fs.writeFileSync(node_path.resolve(sourceRoot, name), content);
|
|
340
262
|
}
|
|
341
263
|
if (removeStaleLockfile) node_fs.rmSync(lockfilePath);
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
`Skipped Free keys (install them in the application instead): ${skipped.join(", ")}`
|
|
345
|
-
);
|
|
346
|
-
}
|
|
347
|
-
log(
|
|
348
|
-
`Scaffolded ${display(sourceRoot)} with ${Object.keys(dependencies).length} Pro package(s).`
|
|
264
|
+
context.log(
|
|
265
|
+
`${created ? "Created" : "Updated"} ${manifest.fontAwesomeProSourcesDir}/ with ${proPins.size} Pro package(s).`
|
|
349
266
|
);
|
|
350
267
|
if (removeStaleLockfile) {
|
|
351
|
-
log(
|
|
352
|
-
`Removed ${
|
|
268
|
+
context.log(
|
|
269
|
+
`Removed ${manifest.fontAwesomeProSourcesDir}/package-lock.json because the Pro pins changed; this install regenerates it.`
|
|
353
270
|
);
|
|
354
271
|
}
|
|
355
|
-
log(
|
|
356
|
-
"Next: run this command with --source-root and without --init, then commit the source project and its package-lock.json."
|
|
357
|
-
);
|
|
358
|
-
return 0;
|
|
359
272
|
}
|
|
360
|
-
async function installSourceProject(sourceRoot,
|
|
361
|
-
const { log, display } = context;
|
|
273
|
+
async function installSourceProject(sourceRoot, token, context) {
|
|
362
274
|
const npmCli = requireNpm(context);
|
|
363
|
-
|
|
364
|
-
if (!node_fs.existsSync(node_path.resolve(sourceRoot, name))) {
|
|
365
|
-
throw new Error(
|
|
366
|
-
`${display(sourceRoot)}/${name} was not found. Check --source-root, or scaffold the project with --init.`
|
|
367
|
-
);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
const npmrc = `${display(sourceRoot)}/.npmrc`;
|
|
275
|
+
const npmrc = `${manifest.fontAwesomeProSourcesDir}/.npmrc`;
|
|
371
276
|
const { fontAwesomeRegistry, hasAuth } = checkNpmrc(
|
|
372
277
|
node_fs.readFileSync(node_path.resolve(sourceRoot, ".npmrc"), "utf8"),
|
|
373
278
|
npmrc
|
|
374
279
|
);
|
|
375
280
|
if (!fontAwesomeRegistry || !hasAuth) {
|
|
376
281
|
throw new Error(
|
|
377
|
-
`${npmrc} must contain @fortawesome:registry=${registry} and ${authKey}=${tokenPlaceholder}.
|
|
282
|
+
`${npmrc} must contain @fortawesome:registry=${registry} and ${authKey}=${tokenPlaceholder}. Rerun with --manifest to rewrite it.`
|
|
378
283
|
);
|
|
379
284
|
}
|
|
380
|
-
const
|
|
381
|
-
if (context.isCi && !
|
|
285
|
+
const locked = node_fs.existsSync(node_path.resolve(sourceRoot, "package-lock.json"));
|
|
286
|
+
if (context.isCi && !locked) {
|
|
382
287
|
throw new Error(
|
|
383
|
-
`${
|
|
288
|
+
`${manifest.fontAwesomeProSourcesDir}/package-lock.json is required in CI. Run setup with --manifest locally first and commit the lockfile.`
|
|
384
289
|
);
|
|
385
290
|
}
|
|
386
|
-
if (context.isCi && values["refresh-lock"]) {
|
|
387
|
-
throw new Error(
|
|
388
|
-
"--refresh-lock updates the lockfile and is a local step. In CI, install from the committed lockfile."
|
|
389
|
-
);
|
|
390
|
-
}
|
|
391
|
-
const locked = hasLockfile && !values["refresh-lock"];
|
|
392
291
|
const environment = {
|
|
393
292
|
...context.env,
|
|
394
293
|
[tokenVariable]: await readToken(context)
|
|
@@ -408,12 +307,119 @@ async function installSourceProject(sourceRoot, values, context) {
|
|
|
408
307
|
env: environment
|
|
409
308
|
});
|
|
410
309
|
if (status !== 0) return status;
|
|
411
|
-
const lockfile = `${
|
|
412
|
-
log(
|
|
310
|
+
const lockfile = `${manifest.fontAwesomeProSourcesDir}/package-lock.json`;
|
|
311
|
+
context.log(
|
|
413
312
|
locked ? `Pro sources installed from ${lockfile}.` : `Pro sources installed. Review and commit ${lockfile}.`
|
|
414
313
|
);
|
|
415
314
|
return 0;
|
|
416
315
|
}
|
|
316
|
+
async function setupFromManifest(values, context) {
|
|
317
|
+
const { log } = context;
|
|
318
|
+
const freeOnly = Boolean(values["free-only"]);
|
|
319
|
+
const proInApp = Boolean(values["pro-in-app"]);
|
|
320
|
+
if (freeOnly && proInApp) {
|
|
321
|
+
throw new Error("Use either --free-only or --pro-in-app, not both.");
|
|
322
|
+
}
|
|
323
|
+
if (context.isCi) {
|
|
324
|
+
throw new Error(
|
|
325
|
+
`--manifest setup changes package.json and is a local step. In CI, run the app's own "npm ci", then featherk-fontawesome-setup without arguments to install ${manifest.fontAwesomeProSourcesDir}/.`
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
const appRoot = context.cwd;
|
|
329
|
+
if (!node_fs.existsSync(node_path.resolve(appRoot, "package.json"))) {
|
|
330
|
+
throw new Error(
|
|
331
|
+
"Run this command from the application root (package.json not found)."
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
const pins = resolvePins(await readKeys(values, context));
|
|
335
|
+
if (!pins.size) {
|
|
336
|
+
throw new Error("No Font Awesome keys selected.");
|
|
337
|
+
}
|
|
338
|
+
const freePins = new Map([...pins].filter(([, pin]) => pin.tier !== "pro"));
|
|
339
|
+
const proPins = new Map([...pins].filter(([, pin]) => pin.tier === "pro"));
|
|
340
|
+
if (freeOnly && proPins.size) {
|
|
341
|
+
throw new Error(
|
|
342
|
+
`--free-only cannot install Pro keys: ${[...proPins.values()].map((pin) => pin.key).join(", ")}.`
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
const npmrcPath = node_path.resolve(appRoot, ".npmrc");
|
|
346
|
+
const config = node_fs.existsSync(npmrcPath) ? node_fs.readFileSync(npmrcPath, "utf8") : "";
|
|
347
|
+
const { fontAwesomeRegistry, hasAuth } = checkNpmrc(config, ".npmrc");
|
|
348
|
+
const sourceRoot = node_path.resolve(appRoot, manifest.fontAwesomeProSourcesDir);
|
|
349
|
+
const isolated = manifest.isFontAwesomeIsolated(appRoot);
|
|
350
|
+
if (proInApp && isolated) {
|
|
351
|
+
throw new Error(
|
|
352
|
+
`${manifest.fontAwesomeProSourcesDir}/ exists, so this app keeps Pro in the isolated source project. Run without --pro-in-app, or remove ${manifest.fontAwesomeProSourcesDir}/ first.`
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
if (!proInApp && fontAwesomeRegistry) {
|
|
356
|
+
throw new Error(
|
|
357
|
+
`.npmrc routes @fortawesome to ${fontAwesomeRegistry}, so this app installs Pro in the app itself. Rerun with --pro-in-app.`
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
if (freeOnly && isolated) {
|
|
361
|
+
throw new Error(
|
|
362
|
+
`${manifest.fontAwesomeProSourcesDir}/ exists, so this app uses Pro. Run without --free-only, or remove ${manifest.fontAwesomeProSourcesDir}/ first.`
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
if (proInApp) {
|
|
366
|
+
const token = proPins.size ? await readToken(context) : void 0;
|
|
367
|
+
if (proPins.size) {
|
|
368
|
+
const missing = [];
|
|
369
|
+
if (!fontAwesomeRegistry) missing.push(npmrcLines[0], npmrcLines[1]);
|
|
370
|
+
if (!hasAuth) missing.push(npmrcLines[2], npmrcLines[3]);
|
|
371
|
+
if (missing.length) {
|
|
372
|
+
const separator = config && !config.endsWith("\n") ? "\n" : "";
|
|
373
|
+
node_fs.writeFileSync(
|
|
374
|
+
npmrcPath,
|
|
375
|
+
`${config}${separator}${missing.join("\n")}
|
|
376
|
+
`
|
|
377
|
+
);
|
|
378
|
+
log(
|
|
379
|
+
`${config ? "Updated" : "Created"} .npmrc with the Font Awesome registry and token placeholder.`
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
const status2 = installIntoApp(pins, proPins.size > 0, token, context);
|
|
384
|
+
if (status2 !== 0) return status2;
|
|
385
|
+
log(lifecycleNote);
|
|
386
|
+
log(
|
|
387
|
+
`Next: commit .npmrc, package.json, and package-lock.json. Configure the Vite plugin with { manifest }. Every later install, including CI, gives ${tokenVariable} only to "npm ci --ignore-scripts"; run needed install scripts and builds without it.`
|
|
388
|
+
);
|
|
389
|
+
return 0;
|
|
390
|
+
}
|
|
391
|
+
if (freePins.size) {
|
|
392
|
+
const status2 = installIntoApp(freePins, false, void 0, context);
|
|
393
|
+
if (status2 !== 0) return status2;
|
|
394
|
+
log(lifecycleNote);
|
|
395
|
+
}
|
|
396
|
+
if (!proPins.size) {
|
|
397
|
+
if (isolated) {
|
|
398
|
+
log(
|
|
399
|
+
`The manifest has no Pro keys; ${manifest.fontAwesomeProSourcesDir}/ is no longer needed and can be removed.`
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
log(
|
|
403
|
+
"Next: commit package.json and package-lock.json. Configure the Vite plugin with { manifest }; no token is needed."
|
|
404
|
+
);
|
|
405
|
+
return 0;
|
|
406
|
+
}
|
|
407
|
+
writeSourceProject(sourceRoot, proPins, context);
|
|
408
|
+
const status = await installSourceProject(sourceRoot, void 0, context);
|
|
409
|
+
if (status !== 0) return status;
|
|
410
|
+
log(
|
|
411
|
+
`Next: commit package.json, package-lock.json, and ${manifest.fontAwesomeProSourcesDir}/. Configure the Vite plugin with { manifest }; builds include Pro icons wherever ${manifest.fontAwesomeProSourcesDir}/ is installed. In CI, run the app's "npm ci" without the token, then featherk-fontawesome-setup with ${tokenVariable}, then the normal build.`
|
|
412
|
+
);
|
|
413
|
+
return 0;
|
|
414
|
+
}
|
|
415
|
+
const lifecycleNote = "Lifecycle scripts were skipped. If needed, run npm rebuild for dependency scripts and the app's own scripts (e.g. npm run prepare --if-present).";
|
|
416
|
+
const removedFlags = [
|
|
417
|
+
"--keys",
|
|
418
|
+
"--source-root",
|
|
419
|
+
"--init",
|
|
420
|
+
"--force",
|
|
421
|
+
"--refresh-lock"
|
|
422
|
+
];
|
|
417
423
|
async function runFontAwesomeSetup(args, io = {}) {
|
|
418
424
|
const cwd = io.cwd ?? process.cwd();
|
|
419
425
|
const env = io.env ?? process.env;
|
|
@@ -425,20 +431,23 @@ async function runFontAwesomeSetup(args, io = {}) {
|
|
|
425
431
|
isCi: Boolean(env.CI) && env.CI !== "false" || Boolean(env.TEAMCITY_VERSION || env.GITHUB_ACTIONS),
|
|
426
432
|
log: io.stdout ?? console.log,
|
|
427
433
|
promptForToken: io.promptForToken ?? promptForTerminalToken,
|
|
428
|
-
runNpm: io.runNpm ?? spawnNpm
|
|
429
|
-
display: (path) => node_path.relative(cwd, path) || "."
|
|
434
|
+
runNpm: io.runNpm ?? spawnNpm
|
|
430
435
|
};
|
|
431
436
|
try {
|
|
437
|
+
const removed = removedFlags.find(
|
|
438
|
+
(flag) => args.some((arg) => arg === flag || arg.startsWith(`${flag}=`))
|
|
439
|
+
);
|
|
440
|
+
if (removed) {
|
|
441
|
+
throw new Error(
|
|
442
|
+
`${removed} was removed in 0.16.0. Run setup with --manifest; Pro sources always live in ${manifest.fontAwesomeProSourcesDir}/, and rerunning with --manifest updates them. Use --help for usage.`
|
|
443
|
+
);
|
|
444
|
+
}
|
|
432
445
|
const { values } = node_util.parseArgs({
|
|
433
446
|
args: [...args],
|
|
434
447
|
options: {
|
|
435
|
-
"source-root": { type: "string" },
|
|
436
448
|
"free-only": { type: "boolean" },
|
|
437
|
-
|
|
438
|
-
keys: { type: "string" },
|
|
449
|
+
"pro-in-app": { type: "boolean" },
|
|
439
450
|
manifest: { type: "string" },
|
|
440
|
-
force: { type: "boolean" },
|
|
441
|
-
"refresh-lock": { type: "boolean" },
|
|
442
451
|
help: { type: "boolean", short: "h" }
|
|
443
452
|
},
|
|
444
453
|
strict: true,
|
|
@@ -448,26 +457,22 @@ async function runFontAwesomeSetup(args, io = {}) {
|
|
|
448
457
|
context.log(usage);
|
|
449
458
|
return 0;
|
|
450
459
|
}
|
|
451
|
-
if (values
|
|
452
|
-
|
|
453
|
-
throw new Error(
|
|
454
|
-
"--init, --force, and --refresh-lock apply only with --source-root."
|
|
455
|
-
);
|
|
456
|
-
}
|
|
457
|
-
return await setupAppRoot(values, context);
|
|
460
|
+
if (values.manifest !== void 0) {
|
|
461
|
+
return await setupFromManifest(values, context);
|
|
458
462
|
}
|
|
459
|
-
if (values["free-only"]) {
|
|
460
|
-
throw new Error(
|
|
461
|
-
"--free-only applies only to app-root setup; an isolated source project holds Pro packages."
|
|
462
|
-
);
|
|
463
|
+
if (values["free-only"] || values["pro-in-app"]) {
|
|
464
|
+
throw new Error("--free-only and --pro-in-app require --manifest.");
|
|
463
465
|
}
|
|
464
|
-
if (
|
|
466
|
+
if (!manifest.isFontAwesomeIsolated(cwd)) {
|
|
465
467
|
throw new Error(
|
|
466
|
-
|
|
468
|
+
`${manifest.fontAwesomeProSourcesDir}/package.json was not found. Run from the application root; for first-time setup, run with --manifest <icons.json>.`
|
|
467
469
|
);
|
|
468
470
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
+
return await installSourceProject(
|
|
472
|
+
node_path.resolve(cwd, manifest.fontAwesomeProSourcesDir),
|
|
473
|
+
void 0,
|
|
474
|
+
context
|
|
475
|
+
);
|
|
471
476
|
} catch (error) {
|
|
472
477
|
stderr(error instanceof Error ? error.message : "Unknown error");
|
|
473
478
|
return 1;
|
|
@@ -30,8 +30,8 @@ export declare function checkNpmrc(config: string, file: string): {
|
|
|
30
30
|
hasAuth: boolean;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
|
-
* Parses setup arguments and runs
|
|
34
|
-
*
|
|
33
|
+
* Parses setup arguments and runs manifest setup, or installs the isolated
|
|
34
|
+
* source project when no arguments are given.
|
|
35
35
|
*
|
|
36
36
|
* @returns `0` on success, npm's exit status when an install fails, and `1`
|
|
37
37
|
* when argument, manifest, config, or environment validation fails.
|