@form8ion/javascript 4.1.2 → 4.3.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.cjs.js CHANGED
@@ -468,7 +468,7 @@ function validate(options) {
468
468
  }).keys({
469
469
  unitTestFrameworks: unitTestFrameworksSchema
470
470
  }).keys({
471
- registries: joi__namespace.object().pattern(joi__namespace.string(), joi__namespace.string().uri())
471
+ registries: joi__namespace.object().pattern(joi__namespace.string(), joi__namespace.string().uri()).default({})
472
472
  });
473
473
  const {
474
474
  error,
@@ -796,7 +796,10 @@ async function scaffoldNpmConfig ({
796
796
  'update-notifier': false
797
797
  }, projectWillNotBeConsumed(projectType) && {
798
798
  'save-exact': true
799
- }), registries && Object.fromEntries(Object.entries(registries).map(([scope, url]) => [`@${scope}:registry`, url])))));
799
+ }), Object.fromEntries(Object.entries(registries).filter(([scope]) => 'publish' !== scope).map(([scope, url]) => {
800
+ if ('registry' === scope) return ['registry', url];
801
+ return [`@${scope}:registry`, url];
802
+ })))));
800
803
  return {
801
804
  scripts: {
802
805
  'lint:peer': 'npm ls >/dev/null'
@@ -1099,7 +1102,8 @@ async function scaffoldPackageType ({
1099
1102
  packageTypes,
1100
1103
  tests,
1101
1104
  decisions,
1102
- dialect
1105
+ dialect,
1106
+ publishRegistry
1103
1107
  }) {
1104
1108
  cliMessages.info('Scaffolding Package Details');
1105
1109
  const detailsForBuild = await buildDetails({
@@ -1151,9 +1155,11 @@ async function scaffoldPackageType ({
1151
1155
  return deepmerge__default["default"].all([{
1152
1156
  packageProperties: _objectSpread2({
1153
1157
  files: ['example.js'],
1154
- publishConfig: {
1158
+ publishConfig: _objectSpread2({
1155
1159
  access: 'Public' === visibility ? 'public' : 'restricted'
1156
- }
1160
+ }, publishRegistry && {
1161
+ registry: publishRegistry
1162
+ })
1157
1163
  }, 'Public' === visibility && {
1158
1164
  runkitExampleFilename: './example.js'
1159
1165
  }),
@@ -1252,7 +1258,8 @@ async function scaffoldCliType ({
1252
1258
  packageName,
1253
1259
  visibility,
1254
1260
  projectRoot,
1255
- dialect
1261
+ dialect,
1262
+ publishRegistry
1256
1263
  }) {
1257
1264
  const rollupResults = await rollup.scaffold({
1258
1265
  projectRoot,
@@ -1278,9 +1285,11 @@ async function scaffoldCliType ({
1278
1285
  version: '0.0.0-semantically-released',
1279
1286
  bin: {},
1280
1287
  files: [`${defaultBuildDirectory}/`],
1281
- publishConfig: {
1288
+ publishConfig: _objectSpread2({
1282
1289
  access: 'Public' === visibility ? 'public' : 'restricted'
1283
- }
1290
+ }, publishRegistry && {
1291
+ registry: publishRegistry
1292
+ })
1284
1293
  },
1285
1294
  eslintConfigs: [],
1286
1295
  nextSteps: []
@@ -1301,7 +1310,8 @@ async function scaffoldProjectType ({
1301
1310
  tests,
1302
1311
  vcs,
1303
1312
  decisions,
1304
- dialect
1313
+ dialect,
1314
+ publishRegistry
1305
1315
  }) {
1306
1316
  switch (projectType) {
1307
1317
  case javascriptCore.projectTypes.PACKAGE:
@@ -1316,7 +1326,8 @@ async function scaffoldProjectType ({
1316
1326
  tests,
1317
1327
  vcs,
1318
1328
  decisions,
1319
- dialect
1329
+ dialect,
1330
+ publishRegistry
1320
1331
  });
1321
1332
 
1322
1333
  case javascriptCore.projectTypes.APPLICATION:
@@ -1335,7 +1346,8 @@ async function scaffoldProjectType ({
1335
1346
  packageName,
1336
1347
  visibility,
1337
1348
  projectRoot,
1338
- dialect
1349
+ dialect,
1350
+ publishRegistry
1339
1351
  });
1340
1352
 
1341
1353
  case javascriptCore.projectTypes.MONOREPO:
@@ -1456,10 +1468,25 @@ function scaffoldBanSensitiveFiles () {
1456
1468
  };
1457
1469
  }
1458
1470
 
1471
+ function buildAllowedHostsList ({
1472
+ packageManager,
1473
+ registries
1474
+ }) {
1475
+ return [...(!registries || registries && !registries.registry ? [packageManager] : []), ...Object.values(Object.fromEntries(Object.entries(registries).filter(([scope]) => 'publish' !== scope)))];
1476
+ }
1477
+
1478
+ const lockfileLintSupportedPackageManagers = [javascriptCore.packageManagers.NPM, javascriptCore.packageManagers.YARN];
1479
+
1459
1480
  function determineLockfilePathFor(packageManager) {
1460
- if (javascriptCore.packageManagers.NPM === packageManager) return 'package-lock.json';
1461
- if (javascriptCore.packageManagers.YARN === packageManager) return 'yarn.lock';
1462
- throw new Error(`The ${packageManager} package manager is currently not supported. ` + `Only ${Object.values(javascriptCore.packageManagers).join(' and ')} are currently supported.`);
1481
+ const lockfilePaths = {
1482
+ [javascriptCore.packageManagers.NPM]: 'package-lock.json',
1483
+ [javascriptCore.packageManagers.YARN]: 'yarn.lock'
1484
+ };
1485
+ return lockfilePaths[packageManager];
1486
+ }
1487
+
1488
+ function lockfileLintSupports(packageManager) {
1489
+ return lockfileLintSupportedPackageManagers.includes(packageManager);
1463
1490
  }
1464
1491
 
1465
1492
  async function scaffoldLockfileLint ({
@@ -1467,11 +1494,18 @@ async function scaffoldLockfileLint ({
1467
1494
  packageManager,
1468
1495
  registries
1469
1496
  }) {
1497
+ if (!lockfileLintSupports(packageManager)) {
1498
+ throw new Error(`The ${packageManager} package manager is currently not supported by lockfile-lint. ` + `Only ${lockfileLintSupportedPackageManagers.join(' and ')} are currently supported.`);
1499
+ }
1500
+
1470
1501
  await fs.promises.writeFile(`${projectRoot}/.lockfile-lintrc.json`, JSON.stringify({
1471
1502
  path: determineLockfilePathFor(packageManager),
1472
1503
  type: packageManager,
1473
1504
  'validate-https': true,
1474
- 'allowed-hosts': [packageManager, ...(registries ? Object.values(registries) : [])]
1505
+ 'allowed-hosts': buildAllowedHostsList({
1506
+ packageManager,
1507
+ registries
1508
+ })
1475
1509
  }));
1476
1510
  return {
1477
1511
  devDependencies: ['lockfile-lint'],
@@ -1611,7 +1645,8 @@ async function scaffolder (options) {
1611
1645
  tests,
1612
1646
  vcs,
1613
1647
  decisions,
1614
- dialect
1648
+ dialect,
1649
+ publishRegistry: registries.publish
1615
1650
  });
1616
1651
  const verificationResults = await scaffoldVerification({
1617
1652
  projectRoot,