@form8ion/javascript 13.0.0-alpha.5 → 13.0.0-beta.10
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/example.js +67 -69
- package/lib/index.js +426 -414
- package/lib/index.js.map +1 -1
- package/package.json +14 -22
- package/lib/index.mjs +0 -1792
- package/lib/index.mjs.map +0 -1
package/lib/index.js
CHANGED
|
@@ -1,69 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var sortProperties = require('sort-object-keys');
|
|
32
|
-
|
|
33
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
34
|
-
|
|
35
|
-
function _interopNamespace(e) {
|
|
36
|
-
if (e && e.__esModule) return e;
|
|
37
|
-
var n = Object.create(null);
|
|
38
|
-
if (e) {
|
|
39
|
-
Object.keys(e).forEach(function (k) {
|
|
40
|
-
if (k !== 'default') {
|
|
41
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
42
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () { return e[k]; }
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
n["default"] = e;
|
|
50
|
-
return Object.freeze(n);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
var deepmerge__default = /*#__PURE__*/_interopDefaultLegacy(deepmerge);
|
|
54
|
-
var joi__default = /*#__PURE__*/_interopDefaultLegacy(joi);
|
|
55
|
-
var commitConventionPlugin__namespace = /*#__PURE__*/_interopNamespace(commitConventionPlugin);
|
|
56
|
-
var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa);
|
|
57
|
-
var npmConf__default = /*#__PURE__*/_interopDefaultLegacy(npmConf);
|
|
58
|
-
var validatePackageName__default = /*#__PURE__*/_interopDefaultLegacy(validatePackageName);
|
|
59
|
-
var mustache__default = /*#__PURE__*/_interopDefaultLegacy(mustache);
|
|
60
|
-
var mkdir__default = /*#__PURE__*/_interopDefaultLegacy(mkdir);
|
|
61
|
-
var touch__default = /*#__PURE__*/_interopDefaultLegacy(touch);
|
|
62
|
-
var camelcase__default = /*#__PURE__*/_interopDefaultLegacy(camelcase);
|
|
63
|
-
var filedirname__default = /*#__PURE__*/_interopDefaultLegacy(filedirname);
|
|
64
|
-
var huskyPlugin__namespace = /*#__PURE__*/_interopNamespace(huskyPlugin);
|
|
65
|
-
var eslintPlugin__namespace = /*#__PURE__*/_interopNamespace(eslintPlugin);
|
|
66
|
-
var sortProperties__default = /*#__PURE__*/_interopDefaultLegacy(sortProperties);
|
|
1
|
+
import { questionNames as questionNames$2, questions } from '@travi/language-scaffolder-prompts';
|
|
2
|
+
import deepmerge from 'deepmerge';
|
|
3
|
+
import { fileTypes, fileExists, optionsSchemas, validateOptions, applyEnhancers, writeConfigFile } from '@form8ion/core';
|
|
4
|
+
import { scaffoldChoice, projectTypes as projectTypes$1, packageManagers as packageManagers$1, mergeIntoExistingPackageJson, dialects as dialects$1, writePackageJson, DEV_DEPENDENCY_TYPE, PROD_DEPENDENCY_TYPE } from '@form8ion/javascript-core';
|
|
5
|
+
import { prompt as prompt$1 } from '@form8ion/overridable-prompts';
|
|
6
|
+
import joi from 'joi';
|
|
7
|
+
import { scaffold, lift as lift$3 } from '@form8ion/codecov';
|
|
8
|
+
import { write as write$1, load } from '@form8ion/config-file';
|
|
9
|
+
import { info, warn, error } from '@travi/cli-messages';
|
|
10
|
+
import * as commitConventionPlugin from '@form8ion/commit-convention';
|
|
11
|
+
import { scaffold as scaffold$4 } from '@form8ion/commit-convention';
|
|
12
|
+
import execa from '@form8ion/execa-wrapper';
|
|
13
|
+
import npmConf from 'npm-conf';
|
|
14
|
+
import { EOL } from 'os';
|
|
15
|
+
import validatePackageName from 'validate-npm-package-name';
|
|
16
|
+
import { promises } from 'fs';
|
|
17
|
+
import mustache from 'mustache';
|
|
18
|
+
import mkdir from 'make-dir';
|
|
19
|
+
import touch from 'touch';
|
|
20
|
+
import camelcase from 'camelcase';
|
|
21
|
+
import { resolve } from 'path';
|
|
22
|
+
import filedirname from 'filedirname';
|
|
23
|
+
import * as huskyPlugin from '@form8ion/husky';
|
|
24
|
+
import { scaffold as scaffold$3 } from '@form8ion/husky';
|
|
25
|
+
import { promises as promises$1 } from 'node:fs';
|
|
26
|
+
import { stringify, parse } from 'ini';
|
|
27
|
+
import { scaffold as scaffold$2 } from '@form8ion/prettier';
|
|
28
|
+
import * as eslintPlugin from '@form8ion/eslint';
|
|
29
|
+
import { scaffold as scaffold$1, test as test$1 } from '@form8ion/eslint';
|
|
30
|
+
import sortProperties from 'sort-object-keys';
|
|
67
31
|
|
|
68
32
|
const questionNames$1 = {
|
|
69
33
|
UNIT_TEST_FRAMEWORK: 'unitTestFramework',
|
|
@@ -84,9 +48,9 @@ const questionNames$1 = {
|
|
|
84
48
|
};
|
|
85
49
|
|
|
86
50
|
async function scaffoldC8 ({projectRoot}) {
|
|
87
|
-
await
|
|
51
|
+
await write$1({
|
|
88
52
|
name: 'c8',
|
|
89
|
-
format:
|
|
53
|
+
format: fileTypes.JSON,
|
|
90
54
|
path: projectRoot,
|
|
91
55
|
config: {
|
|
92
56
|
reporter: ['lcov', 'text-summary', 'html'],
|
|
@@ -102,27 +66,27 @@ async function scaffoldC8 ({projectRoot}) {
|
|
|
102
66
|
}
|
|
103
67
|
|
|
104
68
|
async function scaffoldCoverage ({projectRoot, vcs, visibility, pathWithinParent}) {
|
|
105
|
-
return
|
|
69
|
+
return deepmerge(await scaffoldC8({projectRoot}), await scaffold({vcs, visibility, pathWithinParent}));
|
|
106
70
|
}
|
|
107
71
|
|
|
108
72
|
function nycIsConfigured ({projectRoot}) {
|
|
109
|
-
return
|
|
73
|
+
return fileExists(`${projectRoot}/.nycrc`);
|
|
110
74
|
}
|
|
111
75
|
|
|
112
76
|
async function removeDependencies ({packageManager, dependencies}) {
|
|
113
|
-
await
|
|
77
|
+
await execa(packageManager, ['remove', ...dependencies]);
|
|
114
78
|
}
|
|
115
79
|
|
|
116
80
|
async function removeNyc ({projectRoot, packageManager}) {
|
|
117
81
|
await Promise.all([
|
|
118
|
-
|
|
119
|
-
|
|
82
|
+
promises.unlink(`${projectRoot}/.nycrc`),
|
|
83
|
+
promises.rm(`${projectRoot}/.nyc_output`, {recursive: true, force: true}),
|
|
120
84
|
removeDependencies({packageManager, dependencies: ['nyc', '@istanbuljs/nyc-config-babel', 'babel-plugin-istanbul']})
|
|
121
85
|
]);
|
|
122
86
|
}
|
|
123
87
|
|
|
124
88
|
async function lift$2({projectRoot, packageManager, vcs}) {
|
|
125
|
-
const codecovResults = await
|
|
89
|
+
const codecovResults = await lift$3({projectRoot, packageManager, vcs});
|
|
126
90
|
|
|
127
91
|
if (await nycIsConfigured({projectRoot})) {
|
|
128
92
|
const [c8Results] = await Promise.all([
|
|
@@ -130,7 +94,7 @@ async function lift$2({projectRoot, packageManager, vcs}) {
|
|
|
130
94
|
removeNyc({projectRoot, packageManager})
|
|
131
95
|
]);
|
|
132
96
|
|
|
133
|
-
return
|
|
97
|
+
return deepmerge.all([
|
|
134
98
|
c8Results,
|
|
135
99
|
codecovResults,
|
|
136
100
|
{
|
|
@@ -147,10 +111,10 @@ async function lift$2({projectRoot, packageManager, vcs}) {
|
|
|
147
111
|
}
|
|
148
112
|
|
|
149
113
|
function c8IsConfigured ({projectRoot}) {
|
|
150
|
-
return
|
|
114
|
+
return fileExists(`${projectRoot}/.c8rc.json`);
|
|
151
115
|
}
|
|
152
116
|
|
|
153
|
-
async function tester$
|
|
117
|
+
async function tester$5 ({projectRoot}) {
|
|
154
118
|
const [c8Exists, nycExists] = await Promise.all([c8IsConfigured({projectRoot}), nycIsConfigured({projectRoot})]);
|
|
155
119
|
|
|
156
120
|
return c8Exists || nycExists;
|
|
@@ -158,44 +122,144 @@ async function tester$4 ({projectRoot}) {
|
|
|
158
122
|
|
|
159
123
|
var coveragePlugin = /*#__PURE__*/Object.freeze({
|
|
160
124
|
__proto__: null,
|
|
161
|
-
scaffold: scaffoldCoverage,
|
|
162
125
|
lift: lift$2,
|
|
163
|
-
|
|
126
|
+
scaffold: scaffoldCoverage,
|
|
127
|
+
test: tester$5
|
|
164
128
|
});
|
|
165
129
|
|
|
166
130
|
async function chooseFramework ({frameworks, decisions}) {
|
|
167
131
|
if (!Object.keys(frameworks).length) return 'Other';
|
|
168
132
|
|
|
169
|
-
const answers = await
|
|
133
|
+
const answers = await prompt$1([{
|
|
170
134
|
name: questionNames$1.UNIT_TEST_FRAMEWORK,
|
|
171
135
|
type: 'list',
|
|
172
136
|
message: 'Which type of unit testing framework should be used?',
|
|
173
|
-
choices: [...Object.keys(frameworks),
|
|
137
|
+
choices: [...Object.keys(frameworks), 'Other']
|
|
174
138
|
}], decisions);
|
|
175
139
|
|
|
176
140
|
return answers[questionNames$1.UNIT_TEST_FRAMEWORK];
|
|
177
141
|
}
|
|
178
142
|
|
|
179
|
-
const pluginsSchema =
|
|
143
|
+
const pluginsSchema = joi.object().pattern(/^/, optionsSchemas.form8ionPlugin).default({});
|
|
180
144
|
|
|
181
145
|
async function scaffoldUnitTesting ({projectRoot, frameworks, decisions, visibility, vcs, pathWithinParent, dialect}) {
|
|
182
|
-
const validatedFrameworks =
|
|
146
|
+
const validatedFrameworks = validateOptions(pluginsSchema, frameworks);
|
|
183
147
|
const [framework, coverage] = await Promise.all([
|
|
184
148
|
chooseFramework({frameworks: validatedFrameworks, decisions})
|
|
185
|
-
.then(chosenFramework =>
|
|
149
|
+
.then(chosenFramework => scaffoldChoice(validatedFrameworks, chosenFramework, {projectRoot, dialect})),
|
|
186
150
|
scaffoldCoverage({projectRoot, vcs, visibility, pathWithinParent})
|
|
187
151
|
]);
|
|
188
152
|
|
|
189
|
-
return
|
|
153
|
+
return deepmerge.all([
|
|
190
154
|
{scripts: {'test:unit': 'cross-env NODE_ENV=test c8 run-s test:unit:base'}},
|
|
191
155
|
framework,
|
|
192
156
|
coverage
|
|
193
157
|
]);
|
|
194
158
|
}
|
|
195
159
|
|
|
160
|
+
function tester$4 () {
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async function writeNpmConfig ({projectRoot, config}) {
|
|
165
|
+
await promises$1.writeFile(`${projectRoot}/.npmrc`, stringify(config));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function projectWillNotBeConsumed(projectType) {
|
|
169
|
+
return projectTypes$1.APPLICATION === projectType || projectTypes$1.CLI === projectType;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async function scaffoldNpmConfig ({
|
|
173
|
+
projectRoot,
|
|
174
|
+
projectType,
|
|
175
|
+
registries
|
|
176
|
+
}) {
|
|
177
|
+
await writeNpmConfig({
|
|
178
|
+
projectRoot,
|
|
179
|
+
config: {
|
|
180
|
+
'update-notifier': false,
|
|
181
|
+
...projectWillNotBeConsumed(projectType) && {'save-exact': true},
|
|
182
|
+
...Object.fromEntries(Object.entries(registries)
|
|
183
|
+
.filter(([scope]) => 'publish' !== scope)
|
|
184
|
+
.map(([scope, url]) => {
|
|
185
|
+
if ('registry' === scope) return ['registry', url];
|
|
186
|
+
|
|
187
|
+
return [`@${scope}:registry`, url];
|
|
188
|
+
}))
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
return {scripts: {'lint:peer': 'npm ls >/dev/null'}};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function tester$3 ({projectRoot}) {
|
|
196
|
+
return fileExists(`${projectRoot}/.npmrc`);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async function lifter$5 ({projectRoot}) {
|
|
200
|
+
const pathToConfig = `${projectRoot}/.npmrc`;
|
|
201
|
+
|
|
202
|
+
const {
|
|
203
|
+
provenance,
|
|
204
|
+
'engines-strict': enginesStrict,
|
|
205
|
+
...remainingProperties
|
|
206
|
+
} = parse(await promises$1.readFile(pathToConfig, 'utf-8'));
|
|
207
|
+
|
|
208
|
+
await promises$1.writeFile(pathToConfig, stringify(remainingProperties));
|
|
209
|
+
|
|
210
|
+
return {};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async function readNpmConfig ({projectRoot}) {
|
|
214
|
+
const pathToConfig = `${projectRoot}/.npmrc`;
|
|
215
|
+
|
|
216
|
+
if (!(await fileExists(pathToConfig))) return {};
|
|
217
|
+
|
|
218
|
+
return parse(await promises$1.readFile(pathToConfig, 'utf-8'));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
var npmConfigPlugin = /*#__PURE__*/Object.freeze({
|
|
222
|
+
__proto__: null,
|
|
223
|
+
lift: lifter$5,
|
|
224
|
+
read: readNpmConfig,
|
|
225
|
+
scaffold: scaffoldNpmConfig,
|
|
226
|
+
test: tester$3,
|
|
227
|
+
write: writeNpmConfig
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
function buildRegistriesConfig (registries = {}) {
|
|
231
|
+
return Object.entries(registries)
|
|
232
|
+
.filter(([scope]) => 'publish' !== scope)
|
|
233
|
+
.reduce((acc, [scope, url]) => {
|
|
234
|
+
if ('registry' === scope) return {...acc, registry: url};
|
|
235
|
+
|
|
236
|
+
return {...acc, [`@${scope}:registry`]: url};
|
|
237
|
+
}, {registry: 'https://registry.npmjs.org'});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
async function lifter$4 ({projectRoot, configs}) {
|
|
241
|
+
const registries = buildRegistriesConfig(configs.registries);
|
|
242
|
+
|
|
243
|
+
await writeNpmConfig({
|
|
244
|
+
projectRoot,
|
|
245
|
+
config: {
|
|
246
|
+
...(await readNpmConfig({projectRoot})),
|
|
247
|
+
...registries
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
return {};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
var registriesPlugin = /*#__PURE__*/Object.freeze({
|
|
255
|
+
__proto__: null,
|
|
256
|
+
lift: lifter$4,
|
|
257
|
+
test: tester$4
|
|
258
|
+
});
|
|
259
|
+
|
|
196
260
|
async function scaffoldRemark ({config, projectRoot, projectType, vcs}) {
|
|
197
|
-
await
|
|
198
|
-
format:
|
|
261
|
+
await write$1({
|
|
262
|
+
format: fileTypes.JSON,
|
|
199
263
|
path: projectRoot,
|
|
200
264
|
name: 'remark',
|
|
201
265
|
config: {
|
|
@@ -209,13 +273,13 @@ async function scaffoldRemark ({config, projectRoot, projectType, vcs}) {
|
|
|
209
273
|
plugins: [
|
|
210
274
|
config,
|
|
211
275
|
['remark-toc', {tight: true}],
|
|
212
|
-
...
|
|
276
|
+
...projectTypes$1.PACKAGE === projectType ? [['remark-usage', {heading: 'example'}]] : [],
|
|
213
277
|
...!vcs ? [['validate-links', {repository: false}]] : []
|
|
214
278
|
]
|
|
215
279
|
}
|
|
216
280
|
});
|
|
217
281
|
|
|
218
|
-
return
|
|
282
|
+
return deepmerge(
|
|
219
283
|
{
|
|
220
284
|
devDependencies: [config, 'remark-cli', 'remark-toc'],
|
|
221
285
|
scripts: {
|
|
@@ -223,7 +287,7 @@ async function scaffoldRemark ({config, projectRoot, projectType, vcs}) {
|
|
|
223
287
|
'generate:md': 'remark . --output'
|
|
224
288
|
}
|
|
225
289
|
},
|
|
226
|
-
{...
|
|
290
|
+
{...projectTypes$1.PACKAGE === projectType && {devDependencies: ['remark-usage']}}
|
|
227
291
|
);
|
|
228
292
|
}
|
|
229
293
|
|
|
@@ -234,93 +298,37 @@ async function scaffoldCodeStyle ({
|
|
|
234
298
|
vcs,
|
|
235
299
|
configureLinting
|
|
236
300
|
}) {
|
|
237
|
-
return
|
|
301
|
+
return deepmerge.all(await Promise.all([
|
|
238
302
|
configs.eslint
|
|
239
303
|
&& configureLinting
|
|
240
|
-
&&
|
|
304
|
+
&& scaffold$1({projectRoot, config: configs.eslint}),
|
|
241
305
|
scaffoldRemark({
|
|
242
306
|
projectRoot,
|
|
243
307
|
projectType,
|
|
244
308
|
vcs,
|
|
245
309
|
config: configs.remark || '@form8ion/remark-lint-preset'
|
|
246
310
|
}),
|
|
247
|
-
|
|
311
|
+
scaffold$2({projectRoot, config: configs.prettier})
|
|
248
312
|
].filter(Boolean)));
|
|
249
313
|
}
|
|
250
314
|
|
|
251
|
-
function lifter$
|
|
252
|
-
return
|
|
315
|
+
function lifter$3 (options) {
|
|
316
|
+
return applyEnhancers({options, enhancers: [eslintPlugin]});
|
|
253
317
|
}
|
|
254
318
|
|
|
255
|
-
function tester$
|
|
256
|
-
return
|
|
319
|
+
function tester$2 (options) {
|
|
320
|
+
return test$1(options);
|
|
257
321
|
}
|
|
258
322
|
|
|
259
323
|
var codeStylePlugin = /*#__PURE__*/Object.freeze({
|
|
260
324
|
__proto__: null,
|
|
325
|
+
lift: lifter$3,
|
|
261
326
|
scaffold: scaffoldCodeStyle,
|
|
262
|
-
|
|
263
|
-
test: tester$3
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
async function write$1 ({projectRoot, config}) {
|
|
267
|
-
await node_fs.promises.writeFile(`${projectRoot}/.npmrc`, ini.stringify(config));
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function projectWillNotBeConsumed(projectType) {
|
|
271
|
-
return javascriptCore.projectTypes.APPLICATION === projectType || javascriptCore.projectTypes.CLI === projectType;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
async function scaffoldNpmConfig ({
|
|
275
|
-
projectRoot,
|
|
276
|
-
projectType,
|
|
277
|
-
registries
|
|
278
|
-
}) {
|
|
279
|
-
await write$1({
|
|
280
|
-
projectRoot,
|
|
281
|
-
config: {
|
|
282
|
-
'update-notifier': false,
|
|
283
|
-
...projectWillNotBeConsumed(projectType) && {'save-exact': true},
|
|
284
|
-
...Object.fromEntries(Object.entries(registries)
|
|
285
|
-
.filter(([scope]) => 'publish' !== scope)
|
|
286
|
-
.map(([scope, url]) => {
|
|
287
|
-
if ('registry' === scope) return ['registry', url];
|
|
288
|
-
|
|
289
|
-
return [`@${scope}:registry`, url];
|
|
290
|
-
}))
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
return {scripts: {'lint:peer': 'npm ls >/dev/null'}};
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
function tester$2 ({projectRoot}) {
|
|
298
|
-
return core.fileExists(`${projectRoot}/.npmrc`);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
async function lifter$3 ({projectRoot}) {
|
|
302
|
-
const pathToConfig = `${projectRoot}/.npmrc`;
|
|
303
|
-
|
|
304
|
-
const {
|
|
305
|
-
provenance,
|
|
306
|
-
'engines-strict': enginesStrict,
|
|
307
|
-
...remainingProperties
|
|
308
|
-
} = ini.parse(await node_fs.promises.readFile(pathToConfig, 'utf-8'));
|
|
309
|
-
|
|
310
|
-
await node_fs.promises.writeFile(pathToConfig, ini.stringify(remainingProperties));
|
|
311
|
-
|
|
312
|
-
return {};
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
var npmConfigPlugin = /*#__PURE__*/Object.freeze({
|
|
316
|
-
__proto__: null,
|
|
317
|
-
scaffold: scaffoldNpmConfig,
|
|
318
|
-
test: tester$2,
|
|
319
|
-
lift: lifter$3
|
|
327
|
+
test: tester$2
|
|
320
328
|
});
|
|
321
329
|
|
|
322
330
|
async function test({projectRoot}) {
|
|
323
|
-
const {engines} = JSON.parse(await
|
|
331
|
+
const {engines} = JSON.parse(await promises.readFile(`${projectRoot}/package.json`, 'utf8'));
|
|
324
332
|
|
|
325
333
|
return !!engines?.node;
|
|
326
334
|
}
|
|
@@ -335,27 +343,27 @@ async function lift$1({packageDetails: {name}}) {
|
|
|
335
343
|
|
|
336
344
|
var enginesEnhancer = /*#__PURE__*/Object.freeze({
|
|
337
345
|
__proto__: null,
|
|
338
|
-
|
|
339
|
-
|
|
346
|
+
lift: lift$1,
|
|
347
|
+
test: test
|
|
340
348
|
});
|
|
341
349
|
|
|
342
350
|
function buildDocumentationCommand (packageManager) {
|
|
343
|
-
if (
|
|
344
|
-
if (
|
|
351
|
+
if (packageManagers$1.NPM === packageManager) return 'npm run generate:md';
|
|
352
|
+
if (packageManagers$1.YARN === packageManager) return 'yarn generate:md';
|
|
345
353
|
|
|
346
354
|
throw new Error(
|
|
347
355
|
`The ${packageManager} package manager is currently not supported. `
|
|
348
|
-
+ `Only ${Object.values(
|
|
356
|
+
+ `Only ${Object.values(packageManagers$1).join(' and ')} are currently supported.`
|
|
349
357
|
);
|
|
350
358
|
}
|
|
351
359
|
|
|
352
360
|
function getInstallationCommand(packageManager) {
|
|
353
|
-
if (
|
|
354
|
-
if (
|
|
361
|
+
if (packageManagers$1.NPM === packageManager) return 'npm install';
|
|
362
|
+
if (packageManagers$1.YARN === packageManager) return 'yarn add';
|
|
355
363
|
|
|
356
364
|
throw new Error(
|
|
357
365
|
`The ${packageManager} package manager is currently not supported. `
|
|
358
|
-
+ `Only ${Object.values(
|
|
366
|
+
+ `Only ${Object.values(packageManagers$1).join(' and ')} are currently supported.`
|
|
359
367
|
);
|
|
360
368
|
}
|
|
361
369
|
|
|
@@ -421,7 +429,7 @@ async function liftProvenance ({projectRoot, packageDetails}) {
|
|
|
421
429
|
const {publishConfig: {access}} = packageDetails;
|
|
422
430
|
|
|
423
431
|
if ('public' === access) {
|
|
424
|
-
await
|
|
432
|
+
await mergeIntoExistingPackageJson({projectRoot, config: {publishConfig: {provenance: true}}});
|
|
425
433
|
|
|
426
434
|
return enhanceSlsa({provenance: true});
|
|
427
435
|
}
|
|
@@ -433,9 +441,9 @@ async function liftPublishable ({projectRoot, packageDetails}) {
|
|
|
433
441
|
const {name: packageName, publishConfig: {access: packageAccessLevel}} = packageDetails;
|
|
434
442
|
const homepage = `https://npm.im/${packageName}`;
|
|
435
443
|
|
|
436
|
-
await
|
|
444
|
+
await mergeIntoExistingPackageJson({projectRoot, config: {homepage}});
|
|
437
445
|
|
|
438
|
-
return
|
|
446
|
+
return deepmerge(
|
|
439
447
|
await liftProvenance({packageDetails, projectRoot}),
|
|
440
448
|
{
|
|
441
449
|
homepage,
|
|
@@ -455,7 +463,7 @@ async function scaffoldPublishable ({packageName, packageAccessLevel}) {
|
|
|
455
463
|
async function chooseBundler ({bundlers, decisions}) {
|
|
456
464
|
if (!Object.keys(bundlers).length) return 'Other';
|
|
457
465
|
|
|
458
|
-
const answers = await
|
|
466
|
+
const answers = await prompt$1([{
|
|
459
467
|
name: questionNames$1.PACKAGE_BUNDLER,
|
|
460
468
|
type: 'list',
|
|
461
469
|
message: 'Which bundler should be used?',
|
|
@@ -468,32 +476,32 @@ async function chooseBundler ({bundlers, decisions}) {
|
|
|
468
476
|
async function scaffoldBundler ({projectRoot, projectType, bundlers, dialect, decisions}) {
|
|
469
477
|
const chosenBundler = await chooseBundler({bundlers, decisions});
|
|
470
478
|
|
|
471
|
-
return
|
|
479
|
+
return scaffoldChoice(bundlers, chosenBundler, {projectRoot, projectType, dialect});
|
|
472
480
|
}
|
|
473
481
|
|
|
474
482
|
function determinePathToTemplateFile (fileName) {
|
|
475
|
-
const [, __dirname] =
|
|
483
|
+
const [, __dirname] = filedirname();
|
|
476
484
|
|
|
477
|
-
return
|
|
485
|
+
return resolve(__dirname, '..', 'templates', fileName);
|
|
478
486
|
}
|
|
479
487
|
|
|
480
488
|
const defaultBuildDirectory$2 = 'lib';
|
|
481
489
|
|
|
482
490
|
async function createExample(projectRoot, projectName, dialect) {
|
|
483
|
-
return
|
|
491
|
+
return promises.writeFile(
|
|
484
492
|
`${projectRoot}/example.js`,
|
|
485
|
-
|
|
486
|
-
await
|
|
487
|
-
{projectName:
|
|
493
|
+
mustache.render(
|
|
494
|
+
await promises.readFile(determinePathToTemplateFile('example.mustache'), 'utf8'),
|
|
495
|
+
{projectName: camelcase(projectName), esm: dialect === dialects$1.ESM}
|
|
488
496
|
)
|
|
489
497
|
);
|
|
490
498
|
}
|
|
491
499
|
|
|
492
500
|
async function buildDetailsForCommonJsProject({projectRoot, projectName, provideExample}) {
|
|
493
501
|
await Promise.all([
|
|
494
|
-
|
|
502
|
+
touch(`${projectRoot}/index.js`),
|
|
495
503
|
provideExample
|
|
496
|
-
?
|
|
504
|
+
? promises.writeFile(`${projectRoot}/example.js`, `const ${camelcase(projectName)} = require('.');\n`)
|
|
497
505
|
: Promise.resolve()
|
|
498
506
|
]);
|
|
499
507
|
|
|
@@ -510,16 +518,16 @@ async function buildDetails ({
|
|
|
510
518
|
provideExample,
|
|
511
519
|
decisions
|
|
512
520
|
}) {
|
|
513
|
-
if (
|
|
521
|
+
if (dialects$1.COMMON_JS === dialect) return buildDetailsForCommonJsProject({projectRoot, projectName, provideExample});
|
|
514
522
|
|
|
515
|
-
const pathToCreatedSrcDirectory = await
|
|
523
|
+
const pathToCreatedSrcDirectory = await mkdir(`${projectRoot}/src`);
|
|
516
524
|
const [bundlerResults] = await Promise.all([
|
|
517
|
-
scaffoldBundler({bundlers: packageBundlers, projectRoot, dialect, decisions, projectType:
|
|
525
|
+
scaffoldBundler({bundlers: packageBundlers, projectRoot, dialect, decisions, projectType: projectTypes$1.PACKAGE}),
|
|
518
526
|
provideExample ? await createExample(projectRoot, projectName, dialect) : Promise.resolve,
|
|
519
|
-
|
|
527
|
+
touch(`${pathToCreatedSrcDirectory}/index.js`)
|
|
520
528
|
]);
|
|
521
529
|
|
|
522
|
-
return
|
|
530
|
+
return deepmerge(
|
|
523
531
|
bundlerResults,
|
|
524
532
|
{
|
|
525
533
|
devDependencies: ['rimraf'],
|
|
@@ -560,7 +568,7 @@ async function scaffoldPackageType ({
|
|
|
560
568
|
provideExample,
|
|
561
569
|
publishRegistry
|
|
562
570
|
}) {
|
|
563
|
-
|
|
571
|
+
info('Scaffolding Package Details');
|
|
564
572
|
|
|
565
573
|
const packageAccessLevel = determinePackageAccessLevelFromProjectVisibility({projectVisibility: visibility});
|
|
566
574
|
const [detailsForBuild, publishableResults] = await Promise.all([
|
|
@@ -575,17 +583,17 @@ async function scaffoldPackageType ({
|
|
|
575
583
|
decisions
|
|
576
584
|
}),
|
|
577
585
|
scaffoldPublishable({packageName, packageAccessLevel}),
|
|
578
|
-
|
|
586
|
+
mergeIntoExistingPackageJson({
|
|
579
587
|
projectRoot,
|
|
580
588
|
config: {
|
|
581
|
-
files: ['example.js', ...
|
|
589
|
+
files: ['example.js', ...dialects$1.COMMON_JS === dialect ? ['index.js'] : ['lib/']],
|
|
582
590
|
publishConfig: {
|
|
583
591
|
access: packageAccessLevel,
|
|
584
592
|
...publishRegistry && {registry: publishRegistry}
|
|
585
593
|
},
|
|
586
594
|
sideEffects: false,
|
|
587
595
|
...'Public' === visibility && {runkitExampleFilename: './example.js'},
|
|
588
|
-
...
|
|
596
|
+
...dialects$1.BABEL === dialect && {
|
|
589
597
|
main: './lib/index.js',
|
|
590
598
|
module: './lib/index.mjs',
|
|
591
599
|
exports: {
|
|
@@ -594,11 +602,11 @@ async function scaffoldPackageType ({
|
|
|
594
602
|
import: './lib/index.mjs'
|
|
595
603
|
}
|
|
596
604
|
},
|
|
597
|
-
...
|
|
605
|
+
...dialects$1.ESM === dialect && {
|
|
598
606
|
main: './lib/index.js',
|
|
599
607
|
exports: './lib/index.js'
|
|
600
608
|
},
|
|
601
|
-
...
|
|
609
|
+
...dialects$1.TYPESCRIPT === dialect && {
|
|
602
610
|
main: './lib/index.js',
|
|
603
611
|
module: './lib/index.mjs',
|
|
604
612
|
types: './lib/index.d.ts',
|
|
@@ -612,7 +620,7 @@ async function scaffoldPackageType ({
|
|
|
612
620
|
})
|
|
613
621
|
]);
|
|
614
622
|
|
|
615
|
-
return
|
|
623
|
+
return deepmerge.all([
|
|
616
624
|
publishableResults,
|
|
617
625
|
{
|
|
618
626
|
documentation: scaffoldPackageDocumentation({packageName, visibility, scope, packageManager, provideExample}),
|
|
@@ -637,9 +645,9 @@ async function isPackage ({packageDetails: {exports, publishConfig, bin}}) {
|
|
|
637
645
|
const defaultBuildDirectory$1 = 'public';
|
|
638
646
|
|
|
639
647
|
async function scaffoldApplicationType ({projectRoot}) {
|
|
640
|
-
|
|
648
|
+
info('Scaffolding Application Details');
|
|
641
649
|
|
|
642
|
-
await
|
|
650
|
+
await mergeIntoExistingPackageJson({projectRoot, config: {private: true}});
|
|
643
651
|
|
|
644
652
|
const buildDirectory = defaultBuildDirectory$1;
|
|
645
653
|
|
|
@@ -662,9 +670,9 @@ function isApplication ({packageDetails}) {
|
|
|
662
670
|
}
|
|
663
671
|
|
|
664
672
|
async function scaffoldMonorepoType ({projectRoot}) {
|
|
665
|
-
|
|
673
|
+
info('Scaffolding Monorepo Details');
|
|
666
674
|
|
|
667
|
-
await
|
|
675
|
+
await mergeIntoExistingPackageJson({projectRoot, config: {private: true}});
|
|
668
676
|
|
|
669
677
|
return {
|
|
670
678
|
nextSteps: [{
|
|
@@ -688,9 +696,9 @@ async function scaffoldCliType ({
|
|
|
688
696
|
}) {
|
|
689
697
|
const packageAccessLevel = determinePackageAccessLevelFromProjectVisibility({projectVisibility: visibility});
|
|
690
698
|
const [bundlerResults, publishableResults] = await Promise.all([
|
|
691
|
-
scaffoldBundler({bundlers: packageBundlers, projectRoot, dialect, decisions, projectType:
|
|
699
|
+
scaffoldBundler({bundlers: packageBundlers, projectRoot, dialect, decisions, projectType: projectTypes$1.CLI}),
|
|
692
700
|
scaffoldPublishable({packageName, packageAccessLevel}),
|
|
693
|
-
|
|
701
|
+
mergeIntoExistingPackageJson({
|
|
694
702
|
projectRoot,
|
|
695
703
|
config: {
|
|
696
704
|
bin: {},
|
|
@@ -703,7 +711,7 @@ async function scaffoldCliType ({
|
|
|
703
711
|
})
|
|
704
712
|
]);
|
|
705
713
|
|
|
706
|
-
return
|
|
714
|
+
return deepmerge.all([
|
|
707
715
|
publishableResults,
|
|
708
716
|
bundlerResults,
|
|
709
717
|
{
|
|
@@ -745,7 +753,7 @@ async function scaffoldProjectType ({
|
|
|
745
753
|
publishRegistry
|
|
746
754
|
}) {
|
|
747
755
|
switch (projectType) {
|
|
748
|
-
case
|
|
756
|
+
case projectTypes$1.PACKAGE:
|
|
749
757
|
return scaffoldPackageType({
|
|
750
758
|
projectRoot,
|
|
751
759
|
projectName,
|
|
@@ -759,9 +767,9 @@ async function scaffoldProjectType ({
|
|
|
759
767
|
provideExample,
|
|
760
768
|
publishRegistry
|
|
761
769
|
});
|
|
762
|
-
case
|
|
770
|
+
case projectTypes$1.APPLICATION:
|
|
763
771
|
return scaffoldApplicationType({projectRoot});
|
|
764
|
-
case
|
|
772
|
+
case projectTypes$1.CLI:
|
|
765
773
|
return scaffoldCliType({
|
|
766
774
|
packageName,
|
|
767
775
|
visibility,
|
|
@@ -771,7 +779,7 @@ async function scaffoldProjectType ({
|
|
|
771
779
|
decisions,
|
|
772
780
|
packageBundlers
|
|
773
781
|
});
|
|
774
|
-
case
|
|
782
|
+
case projectTypes$1.MONOREPO:
|
|
775
783
|
return scaffoldMonorepoType({projectRoot});
|
|
776
784
|
case 'Other':
|
|
777
785
|
return {};
|
|
@@ -799,7 +807,7 @@ async function lifter$2 ({projectRoot, packageDetails, vcs}) {
|
|
|
799
807
|
if (vcsRepositoryHostedOnGithub(vcs)) {
|
|
800
808
|
homepage = `https://github.com/${vcs.owner}/${vcs.name}#readme`;
|
|
801
809
|
|
|
802
|
-
await
|
|
810
|
+
await mergeIntoExistingPackageJson({projectRoot, config: {homepage}});
|
|
803
811
|
}
|
|
804
812
|
|
|
805
813
|
return {homepage};
|
|
@@ -807,18 +815,22 @@ async function lifter$2 ({projectRoot, packageDetails, vcs}) {
|
|
|
807
815
|
|
|
808
816
|
var projectTypes = /*#__PURE__*/Object.freeze({
|
|
809
817
|
__proto__: null,
|
|
818
|
+
lift: lifter$2,
|
|
810
819
|
scaffold: scaffoldProjectType,
|
|
811
|
-
test: tester$1
|
|
812
|
-
lift: lifter$2
|
|
820
|
+
test: tester$1
|
|
813
821
|
});
|
|
814
822
|
|
|
815
823
|
function write ({projectRoot, config}) {
|
|
816
|
-
return
|
|
824
|
+
return write$1({path: projectRoot, name: 'babel', format: fileTypes.JSON, config});
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
function loadConfig () {
|
|
828
|
+
return load({name: 'babel'});
|
|
817
829
|
}
|
|
818
830
|
|
|
819
831
|
async function addIgnore ({projectRoot, ignore}) {
|
|
820
832
|
if (ignore) {
|
|
821
|
-
const existingConfig =
|
|
833
|
+
const existingConfig = await loadConfig();
|
|
822
834
|
|
|
823
835
|
await write({projectRoot, config: {...existingConfig, ignore: [`./${ignore}/`]}});
|
|
824
836
|
}
|
|
@@ -844,22 +856,22 @@ async function lifter$1 ({results, projectRoot}) {
|
|
|
844
856
|
}
|
|
845
857
|
|
|
846
858
|
function predicate ({projectRoot}) {
|
|
847
|
-
return
|
|
859
|
+
return fileExists(`${projectRoot}/.babelrc.json`);
|
|
848
860
|
}
|
|
849
861
|
|
|
850
862
|
async function scaffoldTypescript ({config, projectType, projectRoot, testFilenamePattern}) {
|
|
851
863
|
const shareableTsConfigPackage = `${config.scope}/tsconfig`;
|
|
852
864
|
|
|
853
|
-
await
|
|
865
|
+
await writeConfigFile({
|
|
854
866
|
path: projectRoot,
|
|
855
867
|
name: 'tsconfig',
|
|
856
|
-
format:
|
|
868
|
+
format: fileTypes.JSON,
|
|
857
869
|
config: {
|
|
858
870
|
$schema: 'https://json.schemastore.org/tsconfig',
|
|
859
871
|
extends: shareableTsConfigPackage,
|
|
860
872
|
compilerOptions: {
|
|
861
873
|
rootDir: 'src',
|
|
862
|
-
...
|
|
874
|
+
...projectTypes$1.PACKAGE === projectType && {
|
|
863
875
|
outDir: 'lib',
|
|
864
876
|
declaration: true
|
|
865
877
|
}
|
|
@@ -878,9 +890,9 @@ async function scaffoldTypescript ({config, projectType, projectRoot, testFilena
|
|
|
878
890
|
|
|
879
891
|
function scaffoldDialect ({dialect, projectType, projectRoot, configs, testFilenamePattern}) {
|
|
880
892
|
switch (dialect) {
|
|
881
|
-
case
|
|
893
|
+
case dialects$1.BABEL:
|
|
882
894
|
return scaffoldBabel({preset: configs.babelPreset, projectRoot});
|
|
883
|
-
case
|
|
895
|
+
case dialects$1.TYPESCRIPT:
|
|
884
896
|
return scaffoldTypescript({config: configs.typescript, projectType, projectRoot, testFilenamePattern});
|
|
885
897
|
default:
|
|
886
898
|
return {};
|
|
@@ -889,11 +901,22 @@ function scaffoldDialect ({dialect, projectType, projectRoot, configs, testFilen
|
|
|
889
901
|
|
|
890
902
|
var dialects = /*#__PURE__*/Object.freeze({
|
|
891
903
|
__proto__: null,
|
|
904
|
+
lift: lifter$1,
|
|
892
905
|
scaffold: scaffoldDialect,
|
|
893
|
-
test: predicate
|
|
894
|
-
lift: lifter$1
|
|
906
|
+
test: predicate
|
|
895
907
|
});
|
|
896
908
|
|
|
909
|
+
function buildPackageName (projectName, scope) {
|
|
910
|
+
const name = `${scope ? `@${scope}/` : ''}${projectName}`;
|
|
911
|
+
|
|
912
|
+
const {validForNewPackages, errors} = validatePackageName(name);
|
|
913
|
+
|
|
914
|
+
if (validForNewPackages) return name;
|
|
915
|
+
if (1 === errors.length && errors.includes('name cannot start with a period')) return projectName.slice(1);
|
|
916
|
+
|
|
917
|
+
throw new Error(`The package name ${name} is invalid:${EOL}\t* ${errors.join(`${EOL}\t* `)}`);
|
|
918
|
+
}
|
|
919
|
+
|
|
897
920
|
function buildPackageDetails ({
|
|
898
921
|
packageName,
|
|
899
922
|
dialect,
|
|
@@ -905,7 +928,7 @@ function buildPackageDetails ({
|
|
|
905
928
|
name: packageName,
|
|
906
929
|
description,
|
|
907
930
|
license,
|
|
908
|
-
type:
|
|
931
|
+
type: dialects$1.ESM === dialect ? 'module' : 'commonjs',
|
|
909
932
|
author: `${author.name}${author.email ? ` <${author.email}>` : ''}${author.url ? ` (${author.url})` : ''}`,
|
|
910
933
|
scripts: {}
|
|
911
934
|
};
|
|
@@ -913,29 +936,33 @@ function buildPackageDetails ({
|
|
|
913
936
|
|
|
914
937
|
async function scaffoldPackage ({
|
|
915
938
|
projectRoot,
|
|
939
|
+
projectName,
|
|
940
|
+
scope,
|
|
916
941
|
dialect,
|
|
917
|
-
packageName,
|
|
918
942
|
license,
|
|
919
943
|
author,
|
|
920
944
|
description
|
|
921
945
|
}) {
|
|
922
|
-
|
|
946
|
+
info('Configuring package.json');
|
|
923
947
|
|
|
924
|
-
const
|
|
925
|
-
packageName,
|
|
926
|
-
dialect,
|
|
927
|
-
license,
|
|
928
|
-
author,
|
|
929
|
-
description
|
|
930
|
-
});
|
|
948
|
+
const packageName = buildPackageName(projectName, scope);
|
|
931
949
|
|
|
932
|
-
await
|
|
950
|
+
await writePackageJson({
|
|
951
|
+
projectRoot,
|
|
952
|
+
config: await buildPackageDetails({
|
|
953
|
+
packageName,
|
|
954
|
+
dialect,
|
|
955
|
+
license,
|
|
956
|
+
author,
|
|
957
|
+
description
|
|
958
|
+
})
|
|
959
|
+
});
|
|
933
960
|
|
|
934
|
-
return {};
|
|
961
|
+
return {packageName};
|
|
935
962
|
}
|
|
936
963
|
|
|
937
964
|
function sortPackageProperties (packageContents) {
|
|
938
|
-
return
|
|
965
|
+
return sortProperties(
|
|
939
966
|
packageContents,
|
|
940
967
|
[
|
|
941
968
|
'name',
|
|
@@ -985,19 +1012,19 @@ function defineVcsHostDetails (vcs, pathWithinParent) {
|
|
|
985
1012
|
}
|
|
986
1013
|
|
|
987
1014
|
const details = {
|
|
988
|
-
[
|
|
1015
|
+
[packageManagers$1.NPM]: {
|
|
989
1016
|
installationCommand: 'install',
|
|
990
1017
|
installationFlags: {
|
|
991
|
-
[
|
|
992
|
-
[
|
|
1018
|
+
[DEV_DEPENDENCY_TYPE]: `save-${DEV_DEPENDENCY_TYPE}`,
|
|
1019
|
+
[PROD_DEPENDENCY_TYPE]: `save-${PROD_DEPENDENCY_TYPE}`,
|
|
993
1020
|
exact: 'save-exact'
|
|
994
1021
|
}
|
|
995
1022
|
},
|
|
996
|
-
[
|
|
1023
|
+
[packageManagers$1.YARN]: {
|
|
997
1024
|
installationCommand: 'add',
|
|
998
1025
|
installationFlags: {
|
|
999
|
-
[
|
|
1000
|
-
[
|
|
1026
|
+
[DEV_DEPENDENCY_TYPE]: DEV_DEPENDENCY_TYPE,
|
|
1027
|
+
[PROD_DEPENDENCY_TYPE]: PROD_DEPENDENCY_TYPE,
|
|
1001
1028
|
exact: 'exact'
|
|
1002
1029
|
}
|
|
1003
1030
|
}
|
|
@@ -1015,19 +1042,31 @@ function getExactFlag(manager) {
|
|
|
1015
1042
|
return details[manager].installationFlags.exact;
|
|
1016
1043
|
}
|
|
1017
1044
|
|
|
1018
|
-
async function install$1 (dependencies, dependenciesType, projectRoot, packageManager =
|
|
1045
|
+
async function install$1 (dependencies, dependenciesType, projectRoot, packageManager = packageManagers$1.NPM) {
|
|
1019
1046
|
if (dependencies.length) {
|
|
1020
|
-
|
|
1047
|
+
info(`Installing ${dependenciesType} dependencies`, {level: 'secondary'});
|
|
1021
1048
|
|
|
1022
|
-
await
|
|
1049
|
+
await execa(
|
|
1023
1050
|
`. ~/.nvm/nvm.sh && nvm use && ${packageManager} ${
|
|
1024
1051
|
getInstallationCommandFor(packageManager)
|
|
1025
1052
|
} ${[...new Set(dependencies)].join(' ')} --${getDependencyTypeFlag(packageManager, dependenciesType)}${
|
|
1026
|
-
|
|
1053
|
+
DEV_DEPENDENCY_TYPE === dependenciesType ? ` --${getExactFlag(packageManager)}` : ''
|
|
1027
1054
|
}`,
|
|
1028
1055
|
{shell: true, cwd: projectRoot}
|
|
1029
1056
|
);
|
|
1030
|
-
} else
|
|
1057
|
+
} else warn(`No ${dependenciesType} dependencies to install`);
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
async function processDependencies ({dependencies, devDependencies, projectRoot, packageManager}) {
|
|
1061
|
+
info('Processing dependencies');
|
|
1062
|
+
|
|
1063
|
+
try {
|
|
1064
|
+
await install$1(dependencies || [], PROD_DEPENDENCY_TYPE, projectRoot, packageManager);
|
|
1065
|
+
await install$1(devDependencies || [], DEV_DEPENDENCY_TYPE, projectRoot, packageManager);
|
|
1066
|
+
} catch (e) {
|
|
1067
|
+
error('Failed to update dependencies');
|
|
1068
|
+
error(e, {level: 'secondary'});
|
|
1069
|
+
}
|
|
1031
1070
|
}
|
|
1032
1071
|
|
|
1033
1072
|
function projectWillBeTested(scripts) {
|
|
@@ -1063,55 +1102,43 @@ async function liftPackage ({
|
|
|
1063
1102
|
vcs,
|
|
1064
1103
|
pathWithinParent
|
|
1065
1104
|
}) {
|
|
1066
|
-
|
|
1067
|
-
cliMessages.info('Updating `package.json`', {level: 'secondary'});
|
|
1105
|
+
info('Updating `package.json`', {level: 'secondary'});
|
|
1068
1106
|
|
|
1069
|
-
|
|
1107
|
+
const existingPackageJsonContents = JSON.parse(await promises.readFile(`${projectRoot}/package.json`, 'utf-8'));
|
|
1070
1108
|
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
scripts
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
})
|
|
1086
|
-
});
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
cliMessages.info('Installing dependencies');
|
|
1109
|
+
await writePackageJson({
|
|
1110
|
+
projectRoot,
|
|
1111
|
+
config: sortPackageProperties({
|
|
1112
|
+
...existingPackageJsonContents,
|
|
1113
|
+
...defineVcsHostDetails(vcs, pathWithinParent),
|
|
1114
|
+
scripts: liftScripts({
|
|
1115
|
+
existingScripts: existingPackageJsonContents.scripts,
|
|
1116
|
+
scripts
|
|
1117
|
+
}),
|
|
1118
|
+
...tags && {
|
|
1119
|
+
keywords: existingPackageJsonContents.keywords ? [...existingPackageJsonContents.keywords, ...tags] : tags
|
|
1120
|
+
}
|
|
1121
|
+
})
|
|
1122
|
+
});
|
|
1090
1123
|
|
|
1091
|
-
|
|
1092
|
-
await install$1(dependencies || [], javascriptCore.PROD_DEPENDENCY_TYPE, projectRoot, packageManager);
|
|
1093
|
-
await install$1([...devDependencies || []], javascriptCore.DEV_DEPENDENCY_TYPE, projectRoot, packageManager);
|
|
1094
|
-
} catch (e) {
|
|
1095
|
-
cliMessages.error('Failed to install dependencies');
|
|
1096
|
-
cliMessages.error(e, {level: 'secondary'});
|
|
1097
|
-
}
|
|
1124
|
+
await processDependencies({dependencies, devDependencies, projectRoot, packageManager});
|
|
1098
1125
|
}
|
|
1099
1126
|
|
|
1100
1127
|
function determineLockfilePathFor (packageManager) {
|
|
1101
1128
|
const lockfilePaths = {
|
|
1102
|
-
[
|
|
1103
|
-
[
|
|
1129
|
+
[packageManagers$1.NPM]: 'package-lock.json',
|
|
1130
|
+
[packageManagers$1.YARN]: 'yarn.lock'
|
|
1104
1131
|
};
|
|
1105
1132
|
|
|
1106
1133
|
return lockfilePaths[packageManager];
|
|
1107
1134
|
}
|
|
1108
1135
|
|
|
1109
1136
|
function npmIsUsed ({projectRoot}) {
|
|
1110
|
-
return
|
|
1137
|
+
return fileExists(`${projectRoot}/${determineLockfilePathFor(packageManagers$1.NPM)}`);
|
|
1111
1138
|
}
|
|
1112
1139
|
|
|
1113
1140
|
function yarnIsUsed ({projectRoot}) {
|
|
1114
|
-
return
|
|
1141
|
+
return fileExists(`${projectRoot}/${determineLockfilePathFor(packageManagers$1.YARN)}`);
|
|
1115
1142
|
}
|
|
1116
1143
|
|
|
1117
1144
|
async function jsPackageManagerIsUsed ({projectRoot}) {
|
|
@@ -1124,7 +1151,7 @@ async function jsPackageManagerIsUsed ({projectRoot}) {
|
|
|
1124
1151
|
}
|
|
1125
1152
|
|
|
1126
1153
|
async function liftCorepack () {
|
|
1127
|
-
await
|
|
1154
|
+
await execa('corepack', ['use', 'npm@latest']);
|
|
1128
1155
|
}
|
|
1129
1156
|
|
|
1130
1157
|
async function lifter () {
|
|
@@ -1137,11 +1164,11 @@ async function resolvePackageManager ({projectRoot, packageManager}) {
|
|
|
1137
1164
|
if (packageManager) return packageManager;
|
|
1138
1165
|
|
|
1139
1166
|
if (await npmIsUsed({projectRoot})) {
|
|
1140
|
-
return
|
|
1167
|
+
return packageManagers$1.NPM;
|
|
1141
1168
|
}
|
|
1142
1169
|
|
|
1143
1170
|
if (await yarnIsUsed({projectRoot})) {
|
|
1144
|
-
return
|
|
1171
|
+
return packageManagers$1.YARN;
|
|
1145
1172
|
}
|
|
1146
1173
|
|
|
1147
1174
|
throw new Error('Package-manager could not be determined');
|
|
@@ -1149,14 +1176,14 @@ async function resolvePackageManager ({projectRoot, packageManager}) {
|
|
|
1149
1176
|
|
|
1150
1177
|
var packageManagers = /*#__PURE__*/Object.freeze({
|
|
1151
1178
|
__proto__: null,
|
|
1152
|
-
|
|
1153
|
-
lift: lifter,
|
|
1179
|
+
defineLockfilePath: determineLockfilePathFor,
|
|
1154
1180
|
determineCurrent: resolvePackageManager,
|
|
1155
|
-
|
|
1181
|
+
lift: lifter,
|
|
1182
|
+
test: jsPackageManagerIsUsed
|
|
1156
1183
|
});
|
|
1157
1184
|
|
|
1158
|
-
async function lift ({projectRoot, vcs, results, pathWithinParent, enhancers = {}}) {
|
|
1159
|
-
|
|
1185
|
+
async function lift ({projectRoot, vcs, results, pathWithinParent, enhancers = {}, configs = {}}) {
|
|
1186
|
+
info('Lifting JavaScript-specific details');
|
|
1160
1187
|
|
|
1161
1188
|
const {
|
|
1162
1189
|
scripts,
|
|
@@ -1168,28 +1195,29 @@ async function lift ({projectRoot, vcs, results, pathWithinParent, enhancers = {
|
|
|
1168
1195
|
|
|
1169
1196
|
const [packageManager, packageContents] = await Promise.all([
|
|
1170
1197
|
resolvePackageManager({projectRoot, packageManager: manager}),
|
|
1171
|
-
|
|
1198
|
+
promises$1.readFile(`${projectRoot}/package.json`, 'utf8')
|
|
1172
1199
|
]);
|
|
1173
1200
|
|
|
1174
|
-
const enhancerResults = await
|
|
1201
|
+
const enhancerResults = await applyEnhancers({
|
|
1175
1202
|
results,
|
|
1176
1203
|
enhancers: {
|
|
1177
1204
|
...enhancers,
|
|
1178
|
-
huskyPlugin
|
|
1205
|
+
huskyPlugin,
|
|
1179
1206
|
enginesEnhancer,
|
|
1180
1207
|
coveragePlugin,
|
|
1181
|
-
commitConventionPlugin
|
|
1208
|
+
commitConventionPlugin,
|
|
1182
1209
|
dialects,
|
|
1183
1210
|
codeStylePlugin,
|
|
1184
1211
|
npmConfigPlugin,
|
|
1185
1212
|
projectTypes,
|
|
1186
|
-
packageManagers
|
|
1213
|
+
packageManagers,
|
|
1214
|
+
registriesPlugin
|
|
1187
1215
|
},
|
|
1188
|
-
options: {packageManager, projectRoot, vcs, packageDetails: JSON.parse(packageContents)}
|
|
1216
|
+
options: {packageManager, projectRoot, vcs, packageDetails: JSON.parse(packageContents), configs}
|
|
1189
1217
|
});
|
|
1190
1218
|
|
|
1191
1219
|
await liftPackage(
|
|
1192
|
-
|
|
1220
|
+
deepmerge.all([
|
|
1193
1221
|
{projectRoot, scripts, tags, dependencies, devDependencies, packageManager, vcs, pathWithinParent},
|
|
1194
1222
|
enhancerResults
|
|
1195
1223
|
])
|
|
@@ -1198,77 +1226,77 @@ async function lift ({projectRoot, vcs, results, pathWithinParent, enhancers = {
|
|
|
1198
1226
|
return enhancerResults;
|
|
1199
1227
|
}
|
|
1200
1228
|
|
|
1229
|
+
const scopeBasedConfigSchema = joi.object({scope: joi.string().regex(/^@[a-z0-9-]+$/i, 'scope').required()});
|
|
1230
|
+
|
|
1231
|
+
const nameBasedConfigSchema = joi.object({
|
|
1232
|
+
packageName: joi.string().required(),
|
|
1233
|
+
name: joi.string().required()
|
|
1234
|
+
});
|
|
1235
|
+
|
|
1236
|
+
const registriesSchema = joi.object().pattern(joi.string(), joi.string().uri()).default({});
|
|
1237
|
+
|
|
1238
|
+
const visibilitySchema = joi.string().valid('Public', 'Private').required();
|
|
1239
|
+
|
|
1240
|
+
const projectNameSchema = joi.string().regex(/^@\w*\//, {invert: true}).required();
|
|
1241
|
+
|
|
1242
|
+
const vcsSchema = joi.object({
|
|
1243
|
+
host: joi.string().required(),
|
|
1244
|
+
owner: joi.string().required(),
|
|
1245
|
+
name: joi.string().required()
|
|
1246
|
+
});
|
|
1247
|
+
|
|
1201
1248
|
function validate(options) {
|
|
1202
|
-
const schema =
|
|
1203
|
-
.
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
.
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
}),
|
|
1231
|
-
remark: joi__default["default"].string()
|
|
1232
|
-
}).default({})
|
|
1233
|
-
})
|
|
1234
|
-
.keys({
|
|
1235
|
-
plugins: {
|
|
1236
|
-
unitTestFrameworks: pluginsSchema,
|
|
1237
|
-
packageBundlers: pluginsSchema,
|
|
1238
|
-
applicationTypes: pluginsSchema,
|
|
1239
|
-
packageTypes: pluginsSchema,
|
|
1240
|
-
monorepoTypes: pluginsSchema,
|
|
1241
|
-
hosts: pluginsSchema,
|
|
1242
|
-
ciServices: pluginsSchema
|
|
1243
|
-
}
|
|
1244
|
-
})
|
|
1245
|
-
.keys({
|
|
1246
|
-
decisions: joi__default["default"].object()
|
|
1247
|
-
})
|
|
1248
|
-
.keys({registries: joi__default["default"].object().pattern(joi__default["default"].string(), joi__default["default"].string().uri()).default({})});
|
|
1249
|
+
const schema = joi.object({
|
|
1250
|
+
projectRoot: joi.string().required(),
|
|
1251
|
+
projectName: projectNameSchema,
|
|
1252
|
+
visibility: visibilitySchema,
|
|
1253
|
+
license: joi.string().required(),
|
|
1254
|
+
description: joi.string(),
|
|
1255
|
+
pathWithinParent: joi.string(),
|
|
1256
|
+
decisions: joi.object(),
|
|
1257
|
+
vcs: vcsSchema,
|
|
1258
|
+
configs: joi.object({
|
|
1259
|
+
eslint: scopeBasedConfigSchema,
|
|
1260
|
+
typescript: scopeBasedConfigSchema,
|
|
1261
|
+
prettier: scopeBasedConfigSchema,
|
|
1262
|
+
commitlint: nameBasedConfigSchema,
|
|
1263
|
+
babelPreset: nameBasedConfigSchema,
|
|
1264
|
+
remark: joi.string(),
|
|
1265
|
+
registries: registriesSchema
|
|
1266
|
+
}).default({}),
|
|
1267
|
+
plugins: {
|
|
1268
|
+
unitTestFrameworks: pluginsSchema,
|
|
1269
|
+
packageBundlers: pluginsSchema,
|
|
1270
|
+
applicationTypes: pluginsSchema,
|
|
1271
|
+
packageTypes: pluginsSchema,
|
|
1272
|
+
monorepoTypes: pluginsSchema,
|
|
1273
|
+
hosts: pluginsSchema,
|
|
1274
|
+
ciServices: pluginsSchema
|
|
1275
|
+
}
|
|
1276
|
+
}).required();
|
|
1249
1277
|
|
|
1250
|
-
return
|
|
1278
|
+
return validateOptions(schema, options);
|
|
1251
1279
|
}
|
|
1252
1280
|
|
|
1253
1281
|
function buildDialectChoices ({babelPreset, typescript}) {
|
|
1254
1282
|
return [
|
|
1255
|
-
{name: 'Common JS (no transpilation)', value:
|
|
1256
|
-
...babelPreset ? [{name: 'Modern JavaScript (transpiled)', value:
|
|
1257
|
-
{name: 'ESM-only (no transpilation)', value:
|
|
1258
|
-
...typescript ? [{name: 'TypeScript', value:
|
|
1283
|
+
{name: 'Common JS (no transpilation)', value: dialects$1.COMMON_JS, short: 'cjs'},
|
|
1284
|
+
...babelPreset ? [{name: 'Modern JavaScript (transpiled)', value: dialects$1.BABEL, short: 'modern'}] : [],
|
|
1285
|
+
{name: 'ESM-only (no transpilation)', value: dialects$1.ESM, short: 'esm'},
|
|
1286
|
+
...typescript ? [{name: 'TypeScript', value: dialects$1.TYPESCRIPT, short: 'ts'}] : []
|
|
1259
1287
|
];
|
|
1260
1288
|
}
|
|
1261
1289
|
|
|
1262
1290
|
function projectIsCLI(answers) {
|
|
1263
|
-
return
|
|
1291
|
+
return projectTypes$1.CLI === answers[questionNames$1.PROJECT_TYPE];
|
|
1264
1292
|
}
|
|
1265
1293
|
|
|
1266
1294
|
function projectIsPackage(answers) {
|
|
1267
|
-
return
|
|
1295
|
+
return projectTypes$1.PACKAGE === answers[questionNames$1.PROJECT_TYPE];
|
|
1268
1296
|
}
|
|
1269
1297
|
|
|
1270
1298
|
function projectIsApplication(answers) {
|
|
1271
|
-
return
|
|
1299
|
+
return projectTypes$1.APPLICATION === answers[questionNames$1.PROJECT_TYPE];
|
|
1272
1300
|
}
|
|
1273
1301
|
|
|
1274
1302
|
function packageShouldBeScoped(visibility, answers) {
|
|
@@ -1288,8 +1316,8 @@ function scopePromptShouldBePresentedFactory(visibility) {
|
|
|
1288
1316
|
}
|
|
1289
1317
|
|
|
1290
1318
|
function lintingPromptShouldBePresented({
|
|
1291
|
-
[
|
|
1292
|
-
[
|
|
1319
|
+
[questionNames$2.UNIT_TESTS]: unitTested,
|
|
1320
|
+
[questionNames$2.INTEGRATION_TESTS]: integrationTested
|
|
1293
1321
|
}) {
|
|
1294
1322
|
return !unitTested && !integrationTested;
|
|
1295
1323
|
}
|
|
@@ -1333,23 +1361,23 @@ async function prompt(
|
|
|
1333
1361
|
configs,
|
|
1334
1362
|
pathWithinParent
|
|
1335
1363
|
) {
|
|
1336
|
-
const npmConf =
|
|
1364
|
+
const npmConf$1 = npmConf();
|
|
1337
1365
|
|
|
1338
1366
|
let maybeLoggedInNpmUsername;
|
|
1339
1367
|
try {
|
|
1340
|
-
maybeLoggedInNpmUsername = (await
|
|
1368
|
+
maybeLoggedInNpmUsername = (await execa('npm', ['whoami'])).stdout;
|
|
1341
1369
|
} catch (failedExecutionResult) {
|
|
1342
1370
|
if (!decisions[questionNames$1.SCOPE]) {
|
|
1343
|
-
|
|
1371
|
+
warn('No logged in user found with `npm whoami`. Login with `npm login` '
|
|
1344
1372
|
+ 'to use your npm account name as the package scope default.');
|
|
1345
1373
|
}
|
|
1346
1374
|
}
|
|
1347
1375
|
|
|
1348
1376
|
const {
|
|
1349
|
-
[
|
|
1350
|
-
[
|
|
1377
|
+
[questionNames$2.UNIT_TESTS]: unitTested,
|
|
1378
|
+
[questionNames$2.INTEGRATION_TESTS]: integrationTested,
|
|
1351
1379
|
[questionNames$1.PROJECT_TYPE]: projectType,
|
|
1352
|
-
[
|
|
1380
|
+
[questionNames$2.CI_SERVICE]: ci,
|
|
1353
1381
|
[questionNames$1.HOST]: chosenHost,
|
|
1354
1382
|
[questionNames$1.SCOPE]: scope$1,
|
|
1355
1383
|
[questionNames$1.NODE_VERSION_CATEGORY]: nodeVersionCategory,
|
|
@@ -1360,7 +1388,7 @@ async function prompt(
|
|
|
1360
1388
|
[questionNames$1.PROVIDE_EXAMPLE]: provideExample,
|
|
1361
1389
|
[questionNames$1.PACKAGE_MANAGER]: packageManager,
|
|
1362
1390
|
[questionNames$1.DIALECT]: dialect
|
|
1363
|
-
} = await
|
|
1391
|
+
} = await prompt$1([
|
|
1364
1392
|
{
|
|
1365
1393
|
name: questionNames$1.DIALECT,
|
|
1366
1394
|
message: 'Which JavaScript dialect should this project follow?',
|
|
@@ -1379,15 +1407,15 @@ async function prompt(
|
|
|
1379
1407
|
name: questionNames$1.PACKAGE_MANAGER,
|
|
1380
1408
|
message: 'Which package manager will be used with this project?',
|
|
1381
1409
|
type: 'list',
|
|
1382
|
-
choices: Object.values(
|
|
1383
|
-
default:
|
|
1410
|
+
choices: Object.values(packageManagers$1),
|
|
1411
|
+
default: packageManagers$1.NPM
|
|
1384
1412
|
},
|
|
1385
1413
|
{
|
|
1386
1414
|
name: questionNames$1.PROJECT_TYPE,
|
|
1387
1415
|
message: 'What type of JavaScript project is this?',
|
|
1388
1416
|
type: 'list',
|
|
1389
|
-
choices: [...Object.values(
|
|
1390
|
-
default:
|
|
1417
|
+
choices: [...Object.values(projectTypes$1), 'Other'],
|
|
1418
|
+
default: projectTypes$1.PACKAGE
|
|
1391
1419
|
},
|
|
1392
1420
|
...'Private' === visibility ? [] : [{
|
|
1393
1421
|
name: questionNames$1.SHOULD_BE_SCOPED,
|
|
@@ -1404,11 +1432,11 @@ async function prompt(
|
|
|
1404
1432
|
default: maybeLoggedInNpmUsername
|
|
1405
1433
|
},
|
|
1406
1434
|
...authorQuestions({
|
|
1407
|
-
name: npmConf.get('init.author.name'),
|
|
1408
|
-
email: npmConf.get('init.author.email'),
|
|
1409
|
-
url: npmConf.get('init.author.url')
|
|
1435
|
+
name: npmConf$1.get('init.author.name'),
|
|
1436
|
+
email: npmConf$1.get('init.author.email'),
|
|
1437
|
+
url: npmConf$1.get('init.author.url')
|
|
1410
1438
|
}),
|
|
1411
|
-
...
|
|
1439
|
+
...questions(({vcs, ciServices, pathWithinParent})),
|
|
1412
1440
|
{
|
|
1413
1441
|
name: questionNames$1.CONFIGURE_LINTING,
|
|
1414
1442
|
message: 'Will there be source code that should be linted?',
|
|
@@ -1426,7 +1454,7 @@ async function prompt(
|
|
|
1426
1454
|
type: 'list',
|
|
1427
1455
|
message: 'Where will the application be hosted?',
|
|
1428
1456
|
when: projectIsApplication,
|
|
1429
|
-
choices: [...Object.keys(hosts),
|
|
1457
|
+
choices: [...Object.keys(hosts), 'Other']
|
|
1430
1458
|
}
|
|
1431
1459
|
], decisions);
|
|
1432
1460
|
|
|
@@ -1464,10 +1492,14 @@ $ ${packageManager} test
|
|
|
1464
1492
|
};
|
|
1465
1493
|
}
|
|
1466
1494
|
|
|
1495
|
+
function buildBadgesDetails (contributors) {
|
|
1496
|
+
return deepmerge.all(contributors).badges;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1467
1499
|
async function determineLatestVersionOf(nodeVersionCategory) {
|
|
1468
|
-
|
|
1500
|
+
info('Determining version of node', {level: 'secondary'});
|
|
1469
1501
|
|
|
1470
|
-
const {stdout: nvmLsOutput} = await
|
|
1502
|
+
const {stdout: nvmLsOutput} = await execa(
|
|
1471
1503
|
`. ~/.nvm/nvm.sh && nvm ls-remote${('LTS' === nodeVersionCategory) ? ' --lts' : ''}`,
|
|
1472
1504
|
{shell: true}
|
|
1473
1505
|
);
|
|
@@ -1479,9 +1511,9 @@ async function determineLatestVersionOf(nodeVersionCategory) {
|
|
|
1479
1511
|
}
|
|
1480
1512
|
|
|
1481
1513
|
function install(nodeVersionCategory) {
|
|
1482
|
-
|
|
1514
|
+
info(`Installing ${nodeVersionCategory} version of node using nvm`, {level: 'secondary'});
|
|
1483
1515
|
|
|
1484
|
-
const subprocess =
|
|
1516
|
+
const subprocess = execa('. ~/.nvm/nvm.sh && nvm install', {shell: true});
|
|
1485
1517
|
subprocess.stdout.pipe(process.stdout);
|
|
1486
1518
|
return subprocess;
|
|
1487
1519
|
}
|
|
@@ -1490,11 +1522,11 @@ async function scaffoldNodeVersion ({projectRoot, nodeVersionCategory}) {
|
|
|
1490
1522
|
if (!nodeVersionCategory) return undefined;
|
|
1491
1523
|
|
|
1492
1524
|
const lowerCaseCategory = nodeVersionCategory.toLowerCase();
|
|
1493
|
-
|
|
1525
|
+
info(`Configuring ${lowerCaseCategory} version of node`);
|
|
1494
1526
|
|
|
1495
1527
|
const version = await determineLatestVersionOf(nodeVersionCategory);
|
|
1496
1528
|
|
|
1497
|
-
await
|
|
1529
|
+
await promises$1.writeFile(`${projectRoot}/.nvmrc`, version);
|
|
1498
1530
|
|
|
1499
1531
|
await install(nodeVersionCategory);
|
|
1500
1532
|
|
|
@@ -1502,11 +1534,7 @@ async function scaffoldNodeVersion ({projectRoot, nodeVersionCategory}) {
|
|
|
1502
1534
|
}
|
|
1503
1535
|
|
|
1504
1536
|
function nvmIsUsed ({projectRoot}) {
|
|
1505
|
-
return
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
function buildBadgesDetails (contributors) {
|
|
1509
|
-
return deepmerge__default["default"].all(contributors).badges;
|
|
1537
|
+
return fileExists(`${projectRoot}/.nvmrc`);
|
|
1510
1538
|
}
|
|
1511
1539
|
|
|
1512
1540
|
function buildVcsIgnoreLists (vcsIgnoreLists = {}) {
|
|
@@ -1516,25 +1544,14 @@ function buildVcsIgnoreLists (vcsIgnoreLists = {}) {
|
|
|
1516
1544
|
};
|
|
1517
1545
|
}
|
|
1518
1546
|
|
|
1519
|
-
function buildPackageName (projectName, scope) {
|
|
1520
|
-
const name = `${scope ? `@${scope}/` : ''}${projectName}`;
|
|
1521
|
-
|
|
1522
|
-
const {validForNewPackages, errors} = validatePackageName__default["default"](name);
|
|
1523
|
-
|
|
1524
|
-
if (validForNewPackages) return name;
|
|
1525
|
-
if (1 === errors.length && errors.includes('name cannot start with a period')) return projectName.slice(1);
|
|
1526
|
-
|
|
1527
|
-
throw new Error(`The package name ${name} is invalid:${os.EOL}\t* ${errors.join(`${os.EOL}\t* `)}`);
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
1547
|
async function chooseProjectTypePlugin ({types, projectType, decisions}) {
|
|
1531
1548
|
if (!Object.keys(types).length) return 'Other';
|
|
1532
1549
|
|
|
1533
|
-
const answers = await
|
|
1550
|
+
const answers = await prompt$1([{
|
|
1534
1551
|
name: questionNames$1.PROJECT_TYPE_CHOICE,
|
|
1535
1552
|
type: 'list',
|
|
1536
1553
|
message: `What type of ${projectType} is this?`,
|
|
1537
|
-
choices: [...Object.keys(types),
|
|
1554
|
+
choices: [...Object.keys(types), 'Other']
|
|
1538
1555
|
}], decisions);
|
|
1539
1556
|
|
|
1540
1557
|
return answers[questionNames$1.PROJECT_TYPE_CHOICE];
|
|
@@ -1558,7 +1575,7 @@ async function scaffoldProjectTypePlugin ({
|
|
|
1558
1575
|
|
|
1559
1576
|
const chosenType = await chooseProjectTypePlugin({types: pluginsForProjectType, decisions, projectType});
|
|
1560
1577
|
|
|
1561
|
-
return
|
|
1578
|
+
return scaffoldChoice(
|
|
1562
1579
|
pluginsForProjectType,
|
|
1563
1580
|
chosenType,
|
|
1564
1581
|
{projectRoot, projectName, packageName, packageManager, scope, tests, dialect}
|
|
@@ -1587,7 +1604,7 @@ async function scaffoldTesting ({
|
|
|
1587
1604
|
})
|
|
1588
1605
|
: {};
|
|
1589
1606
|
|
|
1590
|
-
return
|
|
1607
|
+
return deepmerge({devDependencies: [...(unit || integration) ? ['@travi/any'] : []], eslint: {}}, unitResults);
|
|
1591
1608
|
}
|
|
1592
1609
|
|
|
1593
1610
|
function buildAllowedHostsList ({packageManager, registries}) {
|
|
@@ -1597,7 +1614,7 @@ function buildAllowedHostsList ({packageManager, registries}) {
|
|
|
1597
1614
|
];
|
|
1598
1615
|
}
|
|
1599
1616
|
|
|
1600
|
-
const lockfileLintSupportedPackageManagers = [
|
|
1617
|
+
const lockfileLintSupportedPackageManagers = [packageManagers$1.NPM, packageManagers$1.YARN];
|
|
1601
1618
|
|
|
1602
1619
|
function lockfileLintSupports(packageManager) {
|
|
1603
1620
|
return lockfileLintSupportedPackageManagers.includes(packageManager);
|
|
@@ -1611,9 +1628,9 @@ async function scaffoldLockfileLint ({projectRoot, packageManager, registries})
|
|
|
1611
1628
|
);
|
|
1612
1629
|
}
|
|
1613
1630
|
|
|
1614
|
-
await
|
|
1631
|
+
await write$1({
|
|
1615
1632
|
name: 'lockfile-lint',
|
|
1616
|
-
format:
|
|
1633
|
+
format: fileTypes.JSON,
|
|
1617
1634
|
path: projectRoot,
|
|
1618
1635
|
config: {
|
|
1619
1636
|
path: determineLockfilePathFor(packageManager),
|
|
@@ -1657,14 +1674,14 @@ async function scaffoldVerification({
|
|
|
1657
1674
|
pathWithinParent
|
|
1658
1675
|
}),
|
|
1659
1676
|
scaffoldLinting({projectRoot, packageManager, registries, vcs, pathWithinParent}),
|
|
1660
|
-
|
|
1677
|
+
scaffold$3({projectRoot, packageManager, pathWithinParent})
|
|
1661
1678
|
]);
|
|
1662
1679
|
|
|
1663
|
-
return
|
|
1680
|
+
return deepmerge.all([testingResults, lintingResults, huskyResults]);
|
|
1664
1681
|
}
|
|
1665
1682
|
|
|
1666
1683
|
async function scaffolder (options) {
|
|
1667
|
-
|
|
1684
|
+
info('Initializing JavaScript project');
|
|
1668
1685
|
|
|
1669
1686
|
const {
|
|
1670
1687
|
projectRoot,
|
|
@@ -1676,7 +1693,6 @@ async function scaffolder (options) {
|
|
|
1676
1693
|
configs,
|
|
1677
1694
|
decisions,
|
|
1678
1695
|
pathWithinParent,
|
|
1679
|
-
registries,
|
|
1680
1696
|
plugins: {
|
|
1681
1697
|
applicationTypes,
|
|
1682
1698
|
packageTypes,
|
|
@@ -1702,13 +1718,13 @@ async function scaffolder (options) {
|
|
|
1702
1718
|
dialect
|
|
1703
1719
|
} = await prompt(ciServices, hosts, visibility, vcs, decisions, configs, pathWithinParent);
|
|
1704
1720
|
|
|
1705
|
-
|
|
1721
|
+
info('Writing project files', {level: 'secondary'});
|
|
1706
1722
|
|
|
1707
|
-
const packageName =
|
|
1708
|
-
await scaffoldPackage({
|
|
1723
|
+
const {packageName} = await scaffoldPackage({
|
|
1709
1724
|
projectRoot,
|
|
1725
|
+
projectName,
|
|
1726
|
+
scope,
|
|
1710
1727
|
dialect,
|
|
1711
|
-
packageName,
|
|
1712
1728
|
license,
|
|
1713
1729
|
author,
|
|
1714
1730
|
description
|
|
@@ -1722,15 +1738,15 @@ async function scaffolder (options) {
|
|
|
1722
1738
|
visibility,
|
|
1723
1739
|
applicationTypes,
|
|
1724
1740
|
packageTypes,
|
|
1725
|
-
packageBundlers,
|
|
1726
1741
|
monorepoTypes,
|
|
1742
|
+
packageBundlers,
|
|
1727
1743
|
scope,
|
|
1728
1744
|
tests,
|
|
1729
1745
|
vcs,
|
|
1730
1746
|
decisions,
|
|
1731
1747
|
dialect,
|
|
1732
1748
|
provideExample,
|
|
1733
|
-
publishRegistry: registries.publish
|
|
1749
|
+
publishRegistry: configs.registries.publish
|
|
1734
1750
|
});
|
|
1735
1751
|
const verificationResults = await scaffoldVerification({
|
|
1736
1752
|
projectRoot,
|
|
@@ -1738,7 +1754,7 @@ async function scaffolder (options) {
|
|
|
1738
1754
|
visibility,
|
|
1739
1755
|
packageManager,
|
|
1740
1756
|
vcs,
|
|
1741
|
-
registries,
|
|
1757
|
+
registries: configs.registries,
|
|
1742
1758
|
tests,
|
|
1743
1759
|
unitTestFrameworks,
|
|
1744
1760
|
decisions,
|
|
@@ -1746,7 +1762,7 @@ async function scaffolder (options) {
|
|
|
1746
1762
|
});
|
|
1747
1763
|
const [nodeVersion, npmResults, dialectResults, codeStyleResults] = await Promise.all([
|
|
1748
1764
|
scaffoldNodeVersion({projectRoot, nodeVersionCategory}),
|
|
1749
|
-
scaffoldNpmConfig({projectType, projectRoot, registries}),
|
|
1765
|
+
scaffoldNpmConfig({projectType, projectRoot, registries: configs.registries}),
|
|
1750
1766
|
scaffoldDialect({
|
|
1751
1767
|
dialect,
|
|
1752
1768
|
configs,
|
|
@@ -1767,20 +1783,20 @@ async function scaffolder (options) {
|
|
|
1767
1783
|
tests,
|
|
1768
1784
|
decisions,
|
|
1769
1785
|
plugins: {
|
|
1770
|
-
[
|
|
1771
|
-
[
|
|
1772
|
-
[
|
|
1786
|
+
[projectTypes$1.PACKAGE]: packageTypes,
|
|
1787
|
+
[projectTypes$1.APPLICATION]: applicationTypes,
|
|
1788
|
+
[projectTypes$1.MONOREPO]: monorepoTypes
|
|
1773
1789
|
}
|
|
1774
1790
|
});
|
|
1775
|
-
const mergedContributions =
|
|
1791
|
+
const mergedContributions = deepmerge.all([
|
|
1776
1792
|
...(await Promise.all([
|
|
1777
|
-
|
|
1793
|
+
scaffoldChoice(
|
|
1778
1794
|
hosts,
|
|
1779
1795
|
chosenHost,
|
|
1780
1796
|
{buildDirectory: `./${projectTypeResults.buildDirectory}`, projectRoot, projectName, nodeVersion}
|
|
1781
1797
|
),
|
|
1782
|
-
|
|
1783
|
-
|
|
1798
|
+
scaffoldChoice(ciServices, ci, {projectRoot, vcs, visibility, projectType, projectName, nodeVersion, tests}),
|
|
1799
|
+
scaffold$4({projectRoot, projectType, configs, pathWithinParent})
|
|
1784
1800
|
])),
|
|
1785
1801
|
projectTypeResults,
|
|
1786
1802
|
verificationResults,
|
|
@@ -1791,7 +1807,7 @@ async function scaffolder (options) {
|
|
|
1791
1807
|
]);
|
|
1792
1808
|
|
|
1793
1809
|
const liftResults = await lift({
|
|
1794
|
-
results:
|
|
1810
|
+
results: deepmerge({devDependencies: ['npm-run-all2'], packageManager}, mergedContributions),
|
|
1795
1811
|
projectRoot,
|
|
1796
1812
|
configs,
|
|
1797
1813
|
vcs,
|
|
@@ -1817,16 +1833,12 @@ async function tester ({projectRoot}) {
|
|
|
1817
1833
|
|
|
1818
1834
|
const jsProjectFound = nvmFound || jsPackageManagerFound;
|
|
1819
1835
|
|
|
1820
|
-
if (jsProjectFound)
|
|
1836
|
+
if (jsProjectFound) info('JavaScript Project Detected');
|
|
1821
1837
|
|
|
1822
1838
|
return jsProjectFound;
|
|
1823
1839
|
}
|
|
1824
1840
|
|
|
1825
|
-
const questionNames = {...
|
|
1841
|
+
const questionNames = {...questionNames$2, ...questionNames$1};
|
|
1826
1842
|
|
|
1827
|
-
|
|
1828
|
-
exports.questionNames = questionNames;
|
|
1829
|
-
exports.scaffold = scaffolder;
|
|
1830
|
-
exports.scaffoldUnitTesting = scaffoldUnitTesting;
|
|
1831
|
-
exports.test = tester;
|
|
1843
|
+
export { lift, questionNames, scaffolder as scaffold, scaffoldUnitTesting, tester as test };
|
|
1832
1844
|
//# sourceMappingURL=index.js.map
|