@form8ion/javascript 11.8.0 → 11.10.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/lib/index.js +87 -41
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +87 -41
- package/lib/index.mjs.map +1 -1
- package/package.json +10 -10
package/lib/index.mjs
CHANGED
|
@@ -11,11 +11,10 @@ import * as commitConventionPlugin from '@form8ion/commit-convention';
|
|
|
11
11
|
import { scaffold as scaffold$5 } from '@form8ion/commit-convention';
|
|
12
12
|
import execa from '@form8ion/execa-wrapper';
|
|
13
13
|
import npmConf from 'npm-conf';
|
|
14
|
-
import { promises } from 'fs';
|
|
15
|
-
import { stringify } from 'ini';
|
|
16
14
|
import { EOL } from 'os';
|
|
17
15
|
import validatePackageName from 'validate-npm-package-name';
|
|
18
16
|
import { scaffold as scaffold$3 } from '@form8ion/rollup';
|
|
17
|
+
import { promises } from 'fs';
|
|
19
18
|
import mustache from 'mustache';
|
|
20
19
|
import mkdir from 'make-dir';
|
|
21
20
|
import touch from 'touch';
|
|
@@ -24,6 +23,7 @@ import { resolve } from 'path';
|
|
|
24
23
|
import filedirname from 'filedirname';
|
|
25
24
|
import * as huskyPlugin from '@form8ion/husky';
|
|
26
25
|
import { scaffold as scaffold$4 } from '@form8ion/husky';
|
|
26
|
+
import { stringify, parse } from 'ini';
|
|
27
27
|
import { scaffold as scaffold$2 } from '@form8ion/prettier';
|
|
28
28
|
import { scaffold as scaffold$1, lift as lift$4, test as test$1 } from '@form8ion/eslint';
|
|
29
29
|
import { promises as promises$1 } from 'node:fs';
|
|
@@ -114,7 +114,7 @@ function c8IsConfigured ({projectRoot}) {
|
|
|
114
114
|
return fileExists(`${projectRoot}/.c8rc.json`);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
async function tester$
|
|
117
|
+
async function tester$4 ({projectRoot}) {
|
|
118
118
|
const [c8Exists, nycExists] = await Promise.all([c8IsConfigured({projectRoot}), nycIsConfigured({projectRoot})]);
|
|
119
119
|
|
|
120
120
|
return c8Exists || nycExists;
|
|
@@ -124,7 +124,7 @@ var coveragePlugin = /*#__PURE__*/Object.freeze({
|
|
|
124
124
|
__proto__: null,
|
|
125
125
|
scaffold: scaffoldCoverage,
|
|
126
126
|
lift: lift$2,
|
|
127
|
-
test: tester$
|
|
127
|
+
test: tester$4
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
const unitTestFrameworksSchema = joi.object().required().pattern(/^/, joi.object({
|
|
@@ -214,11 +214,71 @@ async function scaffoldCodeStyle ({
|
|
|
214
214
|
].filter(Boolean)));
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
+
function lifter$3 (options) {
|
|
218
|
+
return lift$4(options);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function tester$3 (options) {
|
|
222
|
+
return test$1(options);
|
|
223
|
+
}
|
|
224
|
+
|
|
217
225
|
var codeStylePlugin = /*#__PURE__*/Object.freeze({
|
|
218
226
|
__proto__: null,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
227
|
+
scaffold: scaffoldCodeStyle,
|
|
228
|
+
lift: lifter$3,
|
|
229
|
+
test: tester$3
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
function projectWillNotBeConsumed(projectType) {
|
|
233
|
+
return projectTypes$1.APPLICATION === projectType || projectTypes$1.CLI === projectType;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
async function scaffoldNpmConfig ({
|
|
237
|
+
projectRoot,
|
|
238
|
+
projectType,
|
|
239
|
+
registries
|
|
240
|
+
}) {
|
|
241
|
+
await promises.writeFile(
|
|
242
|
+
`${projectRoot}/.npmrc`,
|
|
243
|
+
stringify({
|
|
244
|
+
'update-notifier': false,
|
|
245
|
+
...projectWillNotBeConsumed(projectType) && {'save-exact': true},
|
|
246
|
+
...Object.fromEntries(Object.entries(registries)
|
|
247
|
+
.filter(([scope]) => 'publish' !== scope)
|
|
248
|
+
.map(([scope, url]) => {
|
|
249
|
+
if ('registry' === scope) return ['registry', url];
|
|
250
|
+
|
|
251
|
+
return [`@${scope}:registry`, url];
|
|
252
|
+
}))
|
|
253
|
+
})
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
return {scripts: {'lint:peer': 'npm ls >/dev/null'}};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function tester$2 ({projectRoot}) {
|
|
260
|
+
return fileExists(`${projectRoot}/.npmrc`);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
async function lifter$2 ({projectRoot}) {
|
|
264
|
+
const pathToConfig = `${projectRoot}/.npmrc`;
|
|
265
|
+
|
|
266
|
+
const {
|
|
267
|
+
provenance,
|
|
268
|
+
'engines-strict': enginesStrict,
|
|
269
|
+
...remainingProperties
|
|
270
|
+
} = parse(await promises$1.readFile(pathToConfig, 'utf-8'));
|
|
271
|
+
|
|
272
|
+
await promises$1.writeFile(pathToConfig, stringify(remainingProperties));
|
|
273
|
+
|
|
274
|
+
return {};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
var npmConfigPlugin = /*#__PURE__*/Object.freeze({
|
|
278
|
+
__proto__: null,
|
|
279
|
+
scaffold: scaffoldNpmConfig,
|
|
280
|
+
test: tester$2,
|
|
281
|
+
lift: lifter$2
|
|
222
282
|
});
|
|
223
283
|
|
|
224
284
|
async function test({projectRoot}) {
|
|
@@ -282,10 +342,10 @@ run \`${buildDocumentationCommand(packageManager)}\` to inject the usage example
|
|
|
282
342
|
};
|
|
283
343
|
}
|
|
284
344
|
|
|
285
|
-
function defineBadges (packageName,
|
|
345
|
+
function defineBadges (packageName, accessLevel) {
|
|
286
346
|
return {
|
|
287
347
|
consumer: {
|
|
288
|
-
...'
|
|
348
|
+
...'public' === accessLevel && {
|
|
289
349
|
npm: {
|
|
290
350
|
img: `https://img.shields.io/npm/v/${packageName}?logo=npm`,
|
|
291
351
|
text: 'npm',
|
|
@@ -297,6 +357,10 @@ function defineBadges (packageName, visibility) {
|
|
|
297
357
|
};
|
|
298
358
|
}
|
|
299
359
|
|
|
360
|
+
function determinePackageAccessLevelFromProjectVisibility ({projectVisibility}) {
|
|
361
|
+
return 'Public' === projectVisibility ? 'public' : 'restricted';
|
|
362
|
+
}
|
|
363
|
+
|
|
300
364
|
async function chooseBundler ({bundlers, decisions}) {
|
|
301
365
|
if (!Object.keys(bundlers).length) return 'Other';
|
|
302
366
|
|
|
@@ -407,6 +471,7 @@ async function scaffoldPackageType ({
|
|
|
407
471
|
}) {
|
|
408
472
|
info('Scaffolding Package Details');
|
|
409
473
|
|
|
474
|
+
const packageAccessLevel = determinePackageAccessLevelFromProjectVisibility({projectVisibility: visibility});
|
|
410
475
|
const [detailsForBuild] = await Promise.all([
|
|
411
476
|
buildDetails({
|
|
412
477
|
projectRoot,
|
|
@@ -423,7 +488,7 @@ async function scaffoldPackageType ({
|
|
|
423
488
|
config: {
|
|
424
489
|
files: ['example.js', ...dialects$1.COMMON_JS === dialect ? ['index.js'] : ['lib/']],
|
|
425
490
|
publishConfig: {
|
|
426
|
-
access:
|
|
491
|
+
access: packageAccessLevel,
|
|
427
492
|
...publishRegistry && {registry: publishRegistry}
|
|
428
493
|
},
|
|
429
494
|
sideEffects: false,
|
|
@@ -462,7 +527,7 @@ async function scaffoldPackageType ({
|
|
|
462
527
|
{summary: 'Add the appropriate `save` flag to the installation instructions in the README'},
|
|
463
528
|
{summary: 'Publish pre-release versions to npm until package is stable enough to publish v1.0.0'}
|
|
464
529
|
],
|
|
465
|
-
badges: defineBadges(packageName,
|
|
530
|
+
badges: defineBadges(packageName, packageAccessLevel)
|
|
466
531
|
},
|
|
467
532
|
detailsForBuild
|
|
468
533
|
]);
|
|
@@ -499,9 +564,15 @@ async function liftProvenance ({projectRoot, packageDetails}) {
|
|
|
499
564
|
}
|
|
500
565
|
|
|
501
566
|
async function liftPublishable ({projectRoot, packageDetails}) {
|
|
567
|
+
const {name: packageName, publishConfig: {access: pacakgeAccessLevel}} = packageDetails;
|
|
568
|
+
|
|
502
569
|
return deepmerge(
|
|
503
570
|
await liftProvenance({packageDetails, projectRoot}),
|
|
504
|
-
{
|
|
571
|
+
{
|
|
572
|
+
devDependencies: ['publint'],
|
|
573
|
+
scripts: {'lint:publish': 'publint --strict'},
|
|
574
|
+
badges: defineBadges(packageName, pacakgeAccessLevel)
|
|
575
|
+
}
|
|
505
576
|
);
|
|
506
577
|
}
|
|
507
578
|
|
|
@@ -553,6 +624,7 @@ async function scaffoldMonorepoType ({projectRoot}) {
|
|
|
553
624
|
const defaultBuildDirectory = 'bin';
|
|
554
625
|
|
|
555
626
|
async function scaffoldCliType ({packageName, visibility, projectRoot, dialect, publishRegistry}) {
|
|
627
|
+
const packageAccessLevel = determinePackageAccessLevelFromProjectVisibility({projectVisibility: visibility});
|
|
556
628
|
const [rollupResults] = await Promise.all([
|
|
557
629
|
scaffold$3({projectRoot, dialect, projectType: projectTypes$1.CLI}),
|
|
558
630
|
mergeIntoExistingPackageJson({
|
|
@@ -561,7 +633,7 @@ async function scaffoldCliType ({packageName, visibility, projectRoot, dialect,
|
|
|
561
633
|
bin: {},
|
|
562
634
|
files: [`${defaultBuildDirectory}/`],
|
|
563
635
|
publishConfig: {
|
|
564
|
-
access:
|
|
636
|
+
access: packageAccessLevel,
|
|
565
637
|
...publishRegistry && {registry: publishRegistry}
|
|
566
638
|
}
|
|
567
639
|
}
|
|
@@ -581,7 +653,7 @@ async function scaffoldCliType ({packageName, visibility, projectRoot, dialect,
|
|
|
581
653
|
devDependencies: ['rimraf'],
|
|
582
654
|
vcsIgnore: {files: [], directories: [`/${defaultBuildDirectory}/`]},
|
|
583
655
|
buildDirectory: defaultBuildDirectory,
|
|
584
|
-
badges: defineBadges(packageName,
|
|
656
|
+
badges: defineBadges(packageName, packageAccessLevel),
|
|
585
657
|
nextSteps: []
|
|
586
658
|
}
|
|
587
659
|
);
|
|
@@ -991,6 +1063,7 @@ async function lift ({projectRoot, vcs, results}) {
|
|
|
991
1063
|
commitConventionPlugin,
|
|
992
1064
|
dialects,
|
|
993
1065
|
codeStylePlugin,
|
|
1066
|
+
npmConfigPlugin,
|
|
994
1067
|
projectTypes
|
|
995
1068
|
],
|
|
996
1069
|
options: {packageManager, projectRoot, vcs, packageDetails: JSON.parse(packageContents)}
|
|
@@ -1286,33 +1359,6 @@ async function prompt(
|
|
|
1286
1359
|
};
|
|
1287
1360
|
}
|
|
1288
1361
|
|
|
1289
|
-
function projectWillNotBeConsumed(projectType) {
|
|
1290
|
-
return projectTypes$1.APPLICATION === projectType || projectTypes$1.CLI === projectType;
|
|
1291
|
-
}
|
|
1292
|
-
|
|
1293
|
-
async function scaffoldNpmConfig ({
|
|
1294
|
-
projectRoot,
|
|
1295
|
-
projectType,
|
|
1296
|
-
registries
|
|
1297
|
-
}) {
|
|
1298
|
-
await promises.writeFile(
|
|
1299
|
-
`${projectRoot}/.npmrc`,
|
|
1300
|
-
stringify({
|
|
1301
|
-
'update-notifier': false,
|
|
1302
|
-
...projectWillNotBeConsumed(projectType) && {'save-exact': true},
|
|
1303
|
-
...Object.fromEntries(Object.entries(registries)
|
|
1304
|
-
.filter(([scope]) => 'publish' !== scope)
|
|
1305
|
-
.map(([scope, url]) => {
|
|
1306
|
-
if ('registry' === scope) return ['registry', url];
|
|
1307
|
-
|
|
1308
|
-
return [`@${scope}:registry`, url];
|
|
1309
|
-
}))
|
|
1310
|
-
})
|
|
1311
|
-
);
|
|
1312
|
-
|
|
1313
|
-
return {scripts: {'lint:peer': 'npm ls >/dev/null'}};
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
1362
|
function scaffoldDocumentation ({projectTypeResults, packageManager}) {
|
|
1317
1363
|
return {
|
|
1318
1364
|
toc: `Run \`${buildDocumentationCommand(packageManager)}\` to generate a table of contents`,
|