@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.js
CHANGED
|
@@ -14,11 +14,10 @@ var cliMessages = require('@travi/cli-messages');
|
|
|
14
14
|
var commitConventionPlugin = require('@form8ion/commit-convention');
|
|
15
15
|
var execa = require('@form8ion/execa-wrapper');
|
|
16
16
|
var npmConf = require('npm-conf');
|
|
17
|
-
var fs = require('fs');
|
|
18
|
-
var ini = require('ini');
|
|
19
17
|
var os = require('os');
|
|
20
18
|
var validatePackageName = require('validate-npm-package-name');
|
|
21
19
|
var rollup = require('@form8ion/rollup');
|
|
20
|
+
var fs = require('fs');
|
|
22
21
|
var mustache = require('mustache');
|
|
23
22
|
var mkdir = require('make-dir');
|
|
24
23
|
var touch = require('touch');
|
|
@@ -26,6 +25,7 @@ var camelcase = require('camelcase');
|
|
|
26
25
|
var path = require('path');
|
|
27
26
|
var filedirname = require('filedirname');
|
|
28
27
|
var huskyPlugin = require('@form8ion/husky');
|
|
28
|
+
var ini = require('ini');
|
|
29
29
|
var prettier = require('@form8ion/prettier');
|
|
30
30
|
var eslint = require('@form8ion/eslint');
|
|
31
31
|
var node_fs = require('node:fs');
|
|
@@ -150,7 +150,7 @@ function c8IsConfigured ({projectRoot}) {
|
|
|
150
150
|
return core.fileExists(`${projectRoot}/.c8rc.json`);
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
async function tester$
|
|
153
|
+
async function tester$4 ({projectRoot}) {
|
|
154
154
|
const [c8Exists, nycExists] = await Promise.all([c8IsConfigured({projectRoot}), nycIsConfigured({projectRoot})]);
|
|
155
155
|
|
|
156
156
|
return c8Exists || nycExists;
|
|
@@ -160,7 +160,7 @@ var coveragePlugin = /*#__PURE__*/Object.freeze({
|
|
|
160
160
|
__proto__: null,
|
|
161
161
|
scaffold: scaffoldCoverage,
|
|
162
162
|
lift: lift$2,
|
|
163
|
-
test: tester$
|
|
163
|
+
test: tester$4
|
|
164
164
|
});
|
|
165
165
|
|
|
166
166
|
const unitTestFrameworksSchema = joi__default["default"].object().required().pattern(/^/, joi__default["default"].object({
|
|
@@ -250,11 +250,71 @@ async function scaffoldCodeStyle ({
|
|
|
250
250
|
].filter(Boolean)));
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
+
function lifter$3 (options) {
|
|
254
|
+
return eslint.lift(options);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function tester$3 (options) {
|
|
258
|
+
return eslint.test(options);
|
|
259
|
+
}
|
|
260
|
+
|
|
253
261
|
var codeStylePlugin = /*#__PURE__*/Object.freeze({
|
|
254
262
|
__proto__: null,
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
263
|
+
scaffold: scaffoldCodeStyle,
|
|
264
|
+
lift: lifter$3,
|
|
265
|
+
test: tester$3
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
function projectWillNotBeConsumed(projectType) {
|
|
269
|
+
return javascriptCore.projectTypes.APPLICATION === projectType || javascriptCore.projectTypes.CLI === projectType;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
async function scaffoldNpmConfig ({
|
|
273
|
+
projectRoot,
|
|
274
|
+
projectType,
|
|
275
|
+
registries
|
|
276
|
+
}) {
|
|
277
|
+
await fs.promises.writeFile(
|
|
278
|
+
`${projectRoot}/.npmrc`,
|
|
279
|
+
ini.stringify({
|
|
280
|
+
'update-notifier': false,
|
|
281
|
+
...projectWillNotBeConsumed(projectType) && {'save-exact': true},
|
|
282
|
+
...Object.fromEntries(Object.entries(registries)
|
|
283
|
+
.filter(([scope]) => 'publish' !== scope)
|
|
284
|
+
.map(([scope, url]) => {
|
|
285
|
+
if ('registry' === scope) return ['registry', url];
|
|
286
|
+
|
|
287
|
+
return [`@${scope}:registry`, url];
|
|
288
|
+
}))
|
|
289
|
+
})
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
return {scripts: {'lint:peer': 'npm ls >/dev/null'}};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function tester$2 ({projectRoot}) {
|
|
296
|
+
return core.fileExists(`${projectRoot}/.npmrc`);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
async function lifter$2 ({projectRoot}) {
|
|
300
|
+
const pathToConfig = `${projectRoot}/.npmrc`;
|
|
301
|
+
|
|
302
|
+
const {
|
|
303
|
+
provenance,
|
|
304
|
+
'engines-strict': enginesStrict,
|
|
305
|
+
...remainingProperties
|
|
306
|
+
} = ini.parse(await node_fs.promises.readFile(pathToConfig, 'utf-8'));
|
|
307
|
+
|
|
308
|
+
await node_fs.promises.writeFile(pathToConfig, ini.stringify(remainingProperties));
|
|
309
|
+
|
|
310
|
+
return {};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
var npmConfigPlugin = /*#__PURE__*/Object.freeze({
|
|
314
|
+
__proto__: null,
|
|
315
|
+
scaffold: scaffoldNpmConfig,
|
|
316
|
+
test: tester$2,
|
|
317
|
+
lift: lifter$2
|
|
258
318
|
});
|
|
259
319
|
|
|
260
320
|
async function test({projectRoot}) {
|
|
@@ -318,10 +378,10 @@ run \`${buildDocumentationCommand(packageManager)}\` to inject the usage example
|
|
|
318
378
|
};
|
|
319
379
|
}
|
|
320
380
|
|
|
321
|
-
function defineBadges (packageName,
|
|
381
|
+
function defineBadges (packageName, accessLevel) {
|
|
322
382
|
return {
|
|
323
383
|
consumer: {
|
|
324
|
-
...'
|
|
384
|
+
...'public' === accessLevel && {
|
|
325
385
|
npm: {
|
|
326
386
|
img: `https://img.shields.io/npm/v/${packageName}?logo=npm`,
|
|
327
387
|
text: 'npm',
|
|
@@ -333,6 +393,10 @@ function defineBadges (packageName, visibility) {
|
|
|
333
393
|
};
|
|
334
394
|
}
|
|
335
395
|
|
|
396
|
+
function determinePackageAccessLevelFromProjectVisibility ({projectVisibility}) {
|
|
397
|
+
return 'Public' === projectVisibility ? 'public' : 'restricted';
|
|
398
|
+
}
|
|
399
|
+
|
|
336
400
|
async function chooseBundler ({bundlers, decisions}) {
|
|
337
401
|
if (!Object.keys(bundlers).length) return 'Other';
|
|
338
402
|
|
|
@@ -443,6 +507,7 @@ async function scaffoldPackageType ({
|
|
|
443
507
|
}) {
|
|
444
508
|
cliMessages.info('Scaffolding Package Details');
|
|
445
509
|
|
|
510
|
+
const packageAccessLevel = determinePackageAccessLevelFromProjectVisibility({projectVisibility: visibility});
|
|
446
511
|
const [detailsForBuild] = await Promise.all([
|
|
447
512
|
buildDetails({
|
|
448
513
|
projectRoot,
|
|
@@ -459,7 +524,7 @@ async function scaffoldPackageType ({
|
|
|
459
524
|
config: {
|
|
460
525
|
files: ['example.js', ...javascriptCore.dialects.COMMON_JS === dialect ? ['index.js'] : ['lib/']],
|
|
461
526
|
publishConfig: {
|
|
462
|
-
access:
|
|
527
|
+
access: packageAccessLevel,
|
|
463
528
|
...publishRegistry && {registry: publishRegistry}
|
|
464
529
|
},
|
|
465
530
|
sideEffects: false,
|
|
@@ -498,7 +563,7 @@ async function scaffoldPackageType ({
|
|
|
498
563
|
{summary: 'Add the appropriate `save` flag to the installation instructions in the README'},
|
|
499
564
|
{summary: 'Publish pre-release versions to npm until package is stable enough to publish v1.0.0'}
|
|
500
565
|
],
|
|
501
|
-
badges: defineBadges(packageName,
|
|
566
|
+
badges: defineBadges(packageName, packageAccessLevel)
|
|
502
567
|
},
|
|
503
568
|
detailsForBuild
|
|
504
569
|
]);
|
|
@@ -535,9 +600,15 @@ async function liftProvenance ({projectRoot, packageDetails}) {
|
|
|
535
600
|
}
|
|
536
601
|
|
|
537
602
|
async function liftPublishable ({projectRoot, packageDetails}) {
|
|
603
|
+
const {name: packageName, publishConfig: {access: pacakgeAccessLevel}} = packageDetails;
|
|
604
|
+
|
|
538
605
|
return deepmerge__default["default"](
|
|
539
606
|
await liftProvenance({packageDetails, projectRoot}),
|
|
540
|
-
{
|
|
607
|
+
{
|
|
608
|
+
devDependencies: ['publint'],
|
|
609
|
+
scripts: {'lint:publish': 'publint --strict'},
|
|
610
|
+
badges: defineBadges(packageName, pacakgeAccessLevel)
|
|
611
|
+
}
|
|
541
612
|
);
|
|
542
613
|
}
|
|
543
614
|
|
|
@@ -589,6 +660,7 @@ async function scaffoldMonorepoType ({projectRoot}) {
|
|
|
589
660
|
const defaultBuildDirectory = 'bin';
|
|
590
661
|
|
|
591
662
|
async function scaffoldCliType ({packageName, visibility, projectRoot, dialect, publishRegistry}) {
|
|
663
|
+
const packageAccessLevel = determinePackageAccessLevelFromProjectVisibility({projectVisibility: visibility});
|
|
592
664
|
const [rollupResults] = await Promise.all([
|
|
593
665
|
rollup.scaffold({projectRoot, dialect, projectType: javascriptCore.projectTypes.CLI}),
|
|
594
666
|
javascriptCore.mergeIntoExistingPackageJson({
|
|
@@ -597,7 +669,7 @@ async function scaffoldCliType ({packageName, visibility, projectRoot, dialect,
|
|
|
597
669
|
bin: {},
|
|
598
670
|
files: [`${defaultBuildDirectory}/`],
|
|
599
671
|
publishConfig: {
|
|
600
|
-
access:
|
|
672
|
+
access: packageAccessLevel,
|
|
601
673
|
...publishRegistry && {registry: publishRegistry}
|
|
602
674
|
}
|
|
603
675
|
}
|
|
@@ -617,7 +689,7 @@ async function scaffoldCliType ({packageName, visibility, projectRoot, dialect,
|
|
|
617
689
|
devDependencies: ['rimraf'],
|
|
618
690
|
vcsIgnore: {files: [], directories: [`/${defaultBuildDirectory}/`]},
|
|
619
691
|
buildDirectory: defaultBuildDirectory,
|
|
620
|
-
badges: defineBadges(packageName,
|
|
692
|
+
badges: defineBadges(packageName, packageAccessLevel),
|
|
621
693
|
nextSteps: []
|
|
622
694
|
}
|
|
623
695
|
);
|
|
@@ -1027,6 +1099,7 @@ async function lift ({projectRoot, vcs, results}) {
|
|
|
1027
1099
|
commitConventionPlugin__namespace,
|
|
1028
1100
|
dialects,
|
|
1029
1101
|
codeStylePlugin,
|
|
1102
|
+
npmConfigPlugin,
|
|
1030
1103
|
projectTypes
|
|
1031
1104
|
],
|
|
1032
1105
|
options: {packageManager, projectRoot, vcs, packageDetails: JSON.parse(packageContents)}
|
|
@@ -1322,33 +1395,6 @@ async function prompt(
|
|
|
1322
1395
|
};
|
|
1323
1396
|
}
|
|
1324
1397
|
|
|
1325
|
-
function projectWillNotBeConsumed(projectType) {
|
|
1326
|
-
return javascriptCore.projectTypes.APPLICATION === projectType || javascriptCore.projectTypes.CLI === projectType;
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
async function scaffoldNpmConfig ({
|
|
1330
|
-
projectRoot,
|
|
1331
|
-
projectType,
|
|
1332
|
-
registries
|
|
1333
|
-
}) {
|
|
1334
|
-
await fs.promises.writeFile(
|
|
1335
|
-
`${projectRoot}/.npmrc`,
|
|
1336
|
-
ini.stringify({
|
|
1337
|
-
'update-notifier': false,
|
|
1338
|
-
...projectWillNotBeConsumed(projectType) && {'save-exact': true},
|
|
1339
|
-
...Object.fromEntries(Object.entries(registries)
|
|
1340
|
-
.filter(([scope]) => 'publish' !== scope)
|
|
1341
|
-
.map(([scope, url]) => {
|
|
1342
|
-
if ('registry' === scope) return ['registry', url];
|
|
1343
|
-
|
|
1344
|
-
return [`@${scope}:registry`, url];
|
|
1345
|
-
}))
|
|
1346
|
-
})
|
|
1347
|
-
);
|
|
1348
|
-
|
|
1349
|
-
return {scripts: {'lint:peer': 'npm ls >/dev/null'}};
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
1398
|
function scaffoldDocumentation ({projectTypeResults, packageManager}) {
|
|
1353
1399
|
return {
|
|
1354
1400
|
toc: `Run \`${buildDocumentationCommand(packageManager)}\` to generate a table of contents`,
|