@form8ion/javascript 16.0.0-beta.1 → 16.0.0-beta.3

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 CHANGED
@@ -65,7 +65,7 @@ const projectRoot = process.cwd();
65
65
  await scaffoldJavaScript({
66
66
  projectRoot,
67
67
  projectName: 'project-name',
68
- visibility: 'Public',
68
+ visibility: 'OSS',
69
69
  license: 'MIT',
70
70
  configs: {
71
71
  eslint: {scope: `@${accountName}`},
@@ -121,7 +121,7 @@ await scaffoldUnitTesting({
121
121
  Mocha: {scaffold: options => options},
122
122
  Jest: {scaffold: options => options}
123
123
  },
124
- visibility: 'Public',
124
+ visibility: 'OSS',
125
125
  vcs: {host: 'GitHub', owner: 'foo', name: 'bar'},
126
126
  decisions: {[questionNames.UNIT_TEST_FRAMEWORK]: 'Mocha'}
127
127
  });
package/example.js CHANGED
@@ -34,7 +34,7 @@ const projectRoot = process.cwd();
34
34
  await scaffoldJavaScript({
35
35
  projectRoot,
36
36
  projectName: 'project-name',
37
- visibility: 'Public',
37
+ visibility: 'OSS',
38
38
  license: 'MIT',
39
39
  configs: {
40
40
  eslint: {scope: `@${accountName}`},
@@ -90,7 +90,7 @@ await scaffoldUnitTesting({
90
90
  Mocha: {scaffold: options => options},
91
91
  Jest: {scaffold: options => options}
92
92
  },
93
- visibility: 'Public',
93
+ visibility: 'OSS',
94
94
  vcs: {host: 'GitHub', owner: 'foo', name: 'bar'},
95
95
  decisions: {[questionNames.UNIT_TEST_FRAMEWORK]: 'Mocha'}
96
96
  });
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { questionNames as questionNames$2, questions } from '@travi/language-scaffolder-prompts';
2
2
  import deepmerge from 'deepmerge';
3
- import { scaffoldChoice, dialects as dialects$1, projectTypes as projectTypes$1, packageManagers as packageManagers$1, writePackageJson, PROD_DEPENDENCY_TYPE, DEV_DEPENDENCY_TYPE, mergeIntoExistingPackageJson } from '@form8ion/javascript-core';
3
+ import { scaffoldChoice, dialects as dialects$1, projectTypes as projectTypes$1, packageManagers as packageManagers$1, writeNpmrc, loadNpmrc, writePackageJson, PROD_DEPENDENCY_TYPE, DEV_DEPENDENCY_TYPE, mergeIntoExistingPackageJson } from '@form8ion/javascript-core';
4
4
  import * as commitConventionPlugin from '@form8ion/commit-convention';
5
5
  import { scaffold as scaffold$5 } from '@form8ion/commit-convention';
6
6
  import joi from 'joi';
@@ -17,7 +17,6 @@ import { scaffold as scaffold$2 } from '@form8ion/husky';
17
17
  import { scaffold as scaffold$1, lift as lift$1 } from '@form8ion/codecov';
18
18
  import { scaffold, test } from '@form8ion/c8';
19
19
  import { write as write$1 } from '@form8ion/config-file';
20
- import { stringify, parse } from 'ini';
21
20
  import { scaffold as scaffold$4 } from '@form8ion/prettier';
22
21
  import * as eslintPlugin from '@form8ion/eslint';
23
22
  import { scaffold as scaffold$3, test as test$1 } from '@form8ion/eslint';
@@ -181,7 +180,8 @@ function validate(options) {
181
180
  packageTypes: pluginsSchema,
182
181
  monorepoTypes: pluginsSchema,
183
182
  hosts: pluginsSchema,
184
- ciServices: pluginsSchema
183
+ ciServices: pluginsSchema,
184
+ registries: pluginsSchema
185
185
  }
186
186
  }).required();
187
187
 
@@ -210,7 +210,7 @@ function projectIsApplication$1(answers) {
210
210
  }
211
211
 
212
212
  function packageShouldBeScoped(visibility, answers) {
213
- return 'Private' === visibility || answers[questionNames$1.SHOULD_BE_SCOPED];
213
+ return ['ISS', 'CS'].includes(visibility) || answers[questionNames$1.SHOULD_BE_SCOPED];
214
214
  }
215
215
 
216
216
  function willBePublishedToNpm(answers) {
@@ -234,8 +234,13 @@ function lintingPromptShouldBePresented({
234
234
 
235
235
  function scope(visibility) {
236
236
  return input => {
237
- if (!input && 'Private' === visibility) {
238
- return 'Private packages must be scoped (https://docs.npmjs.com/private-modules/intro#setting-up-your-package)';
237
+ if (!input) {
238
+ if ('CS' === visibility) {
239
+ return 'Closed source packages must be scoped';
240
+ }
241
+ if ('ISS' === visibility) {
242
+ return 'Inner source packages must be scoped';
243
+ }
239
244
  }
240
245
 
241
246
  return true;
@@ -328,7 +333,7 @@ async function prompt(
328
333
  choices: [...Object.values(projectTypes$1), 'Other'],
329
334
  default: projectTypes$1.PACKAGE
330
335
  },
331
- ...'Private' === visibility ? [] : [{
336
+ ...['ISS', 'CS'].includes(visibility) ? [] : [{
332
337
  name: questionNames$1.SHOULD_BE_SCOPED,
333
338
  message: 'Should this package be scoped?',
334
339
  type: 'confirm',
@@ -470,16 +475,12 @@ var dialects = /*#__PURE__*/Object.freeze({
470
475
  test: babelIsInUse
471
476
  });
472
477
 
473
- async function writeNpmConfig({projectRoot, config}) {
474
- await promises.writeFile(`${projectRoot}/.npmrc`, stringify(config));
475
- }
476
-
477
478
  function projectWillNotBeConsumed(projectType) {
478
479
  return projectTypes$1.APPLICATION === projectType || projectTypes$1.CLI === projectType;
479
480
  }
480
481
 
481
482
  async function scaffoldNpmConfiguration({projectRoot, projectType}) {
482
- await writeNpmConfig({
483
+ await writeNpmrc({
483
484
  projectRoot,
484
485
  config: {'update-notifier': false, ...projectWillNotBeConsumed(projectType) && {'save-exact': true}}
485
486
  });
@@ -491,22 +492,14 @@ function npmConfigExists({projectRoot}) {
491
492
  return fileExists(`${projectRoot}/.npmrc`);
492
493
  }
493
494
 
494
- async function readNpmConfig({projectRoot}) {
495
- const pathToConfig = `${projectRoot}/.npmrc`;
496
-
497
- if (!(await fileExists(pathToConfig))) return {};
498
-
499
- return parse(await promises.readFile(pathToConfig, 'utf-8'));
500
- }
501
-
502
495
  async function liftNpmConfig({projectRoot}) {
503
496
  const {
504
497
  provenance,
505
498
  'engines-strict': enginesStrict,
506
499
  ...remainingProperties
507
- } = await readNpmConfig({projectRoot});
500
+ } = await loadNpmrc({projectRoot});
508
501
 
509
- await writeNpmConfig({projectRoot, config: remainingProperties});
502
+ await writeNpmrc({projectRoot, config: remainingProperties});
510
503
 
511
504
  return {};
512
505
  }
@@ -514,10 +507,8 @@ async function liftNpmConfig({projectRoot}) {
514
507
  var npmConfigPlugin = /*#__PURE__*/Object.freeze({
515
508
  __proto__: null,
516
509
  lift: liftNpmConfig,
517
- read: readNpmConfig,
518
510
  scaffold: scaffoldNpmConfiguration,
519
- test: npmConfigExists,
520
- write: writeNpmConfig
511
+ test: npmConfigExists
521
512
  });
522
513
 
523
514
  async function scaffoldNpmPackageManager({projectRoot}) {
@@ -1853,10 +1844,10 @@ function buildRegistriesList(registries = {}) {
1853
1844
  async function updateRegistriesInNpmConfig(registries, projectRoot) {
1854
1845
  const registriesForNpmConfig = buildRegistriesList(registries);
1855
1846
 
1856
- await writeNpmConfig({
1847
+ await writeNpmrc({
1857
1848
  projectRoot,
1858
1849
  config: {
1859
- ...(await readNpmConfig({projectRoot})),
1850
+ ...(await loadNpmrc({projectRoot})),
1860
1851
  ...registriesForNpmConfig
1861
1852
  }
1862
1853
  });