@form8ion/javascript 7.1.1 → 7.2.2
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 +100 -64
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +115 -79
- package/lib/index.mjs.map +1 -1
- package/package.json +6 -6
package/lib/index.js
CHANGED
|
@@ -213,6 +213,90 @@ var enginesEnhancer = /*#__PURE__*/Object.freeze({
|
|
|
213
213
|
lift: lift$1
|
|
214
214
|
});
|
|
215
215
|
|
|
216
|
+
function write ({projectRoot, config}) {
|
|
217
|
+
return configFile.write({path: projectRoot, name: 'babel', format: core.fileTypes.JSON, config});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
async function addIgnore ({projectRoot, ignore}) {
|
|
221
|
+
if (ignore) {
|
|
222
|
+
const existingConfig = JSON.parse(await fs.promises.readFile(`${projectRoot}/.babelrc.json`, 'utf-8'));
|
|
223
|
+
|
|
224
|
+
await write({projectRoot, config: {...existingConfig, ignore: [`./${ignore}/`]}});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
async function scaffoldBabel ({projectRoot, preset}) {
|
|
229
|
+
if (!preset) {
|
|
230
|
+
throw new Error('No babel preset provided. Cannot configure babel transpilation');
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
await write({projectRoot, config: {presets: [preset.name]}});
|
|
234
|
+
|
|
235
|
+
return {
|
|
236
|
+
devDependencies: ['@babel/register', preset.packageName],
|
|
237
|
+
eslint: {}
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
async function lifter ({buildDirectory, projectRoot}) {
|
|
242
|
+
await addIgnore({ignore: buildDirectory, projectRoot});
|
|
243
|
+
|
|
244
|
+
return {};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function predicate ({projectRoot}) {
|
|
248
|
+
return core.fileExists(`${projectRoot}/.babelrc.json`);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
async function scaffoldTypescript ({config, projectType, projectRoot, testFilenamePattern}) {
|
|
252
|
+
const eslintConfigs = ['typescript'];
|
|
253
|
+
const shareableTsConfigPackage = `${config.scope}/tsconfig`;
|
|
254
|
+
|
|
255
|
+
await core.writeConfigFile({
|
|
256
|
+
path: projectRoot,
|
|
257
|
+
name: 'tsconfig',
|
|
258
|
+
format: core.fileTypes.JSON,
|
|
259
|
+
config: {
|
|
260
|
+
$schema: 'https://json.schemastore.org/tsconfig',
|
|
261
|
+
extends: shareableTsConfigPackage,
|
|
262
|
+
compilerOptions: {
|
|
263
|
+
rootDir: 'src',
|
|
264
|
+
...javascriptCore.projectTypes.PACKAGE === projectType && {
|
|
265
|
+
outDir: 'lib',
|
|
266
|
+
declaration: true
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
include: ['src/**/*.ts'],
|
|
270
|
+
...testFilenamePattern && {exclude: [testFilenamePattern]}
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
eslint: {configs: eslintConfigs},
|
|
276
|
+
eslintConfigs,
|
|
277
|
+
devDependencies: ['typescript', shareableTsConfigPackage],
|
|
278
|
+
vcsIgnore: {files: ['tsconfig.tsbuildinfo']}
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function scaffoldDialect ({dialect, projectType, projectRoot, configs, testFilenamePattern}) {
|
|
283
|
+
switch (dialect) {
|
|
284
|
+
case javascriptCore.dialects.BABEL:
|
|
285
|
+
return scaffoldBabel({preset: configs.babelPreset, projectRoot});
|
|
286
|
+
case javascriptCore.dialects.TYPESCRIPT:
|
|
287
|
+
return scaffoldTypescript({config: configs.typescript, projectType, projectRoot, testFilenamePattern});
|
|
288
|
+
default:
|
|
289
|
+
return {};
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
var dialects = /*#__PURE__*/Object.freeze({
|
|
294
|
+
__proto__: null,
|
|
295
|
+
scaffold: scaffoldDialect,
|
|
296
|
+
test: predicate,
|
|
297
|
+
lift: lifter
|
|
298
|
+
});
|
|
299
|
+
|
|
216
300
|
function scaffoldScripts () {
|
|
217
301
|
return {};
|
|
218
302
|
}
|
|
@@ -360,15 +444,24 @@ async function resolvePackageManager ({projectRoot, packageManager}) {
|
|
|
360
444
|
async function lift ({projectRoot, vcs, results}) {
|
|
361
445
|
cliMessages.info('Lifting JavaScript-specific details');
|
|
362
446
|
|
|
363
|
-
const {
|
|
447
|
+
const {
|
|
448
|
+
scripts,
|
|
449
|
+
tags,
|
|
450
|
+
eslintConfigs,
|
|
451
|
+
eslint: eslint$1,
|
|
452
|
+
dependencies,
|
|
453
|
+
devDependencies,
|
|
454
|
+
packageManager: manager,
|
|
455
|
+
buildDirectory
|
|
456
|
+
} = results;
|
|
364
457
|
|
|
365
458
|
const packageManager = await resolvePackageManager({projectRoot, packageManager: manager});
|
|
366
459
|
|
|
367
460
|
const eslintResults = await eslint.lift({projectRoot, configs: [...eslintConfigs || [], ...eslint$1?.configs || []]});
|
|
368
461
|
const enhancerResults = await core.applyEnhancers({
|
|
369
462
|
results,
|
|
370
|
-
enhancers: [huskyPlugin__namespace, enginesEnhancer, coveragePlugin, commitConventionPlugin__namespace],
|
|
371
|
-
options: {packageManager, projectRoot, vcs}
|
|
463
|
+
enhancers: [huskyPlugin__namespace, enginesEnhancer, coveragePlugin, commitConventionPlugin__namespace, dialects],
|
|
464
|
+
options: {packageManager, projectRoot, vcs, buildDirectory}
|
|
372
465
|
});
|
|
373
466
|
|
|
374
467
|
await liftPackage(
|
|
@@ -656,64 +749,6 @@ async function prompt(
|
|
|
656
749
|
};
|
|
657
750
|
}
|
|
658
751
|
|
|
659
|
-
async function scaffoldBabel ({projectRoot, preset, buildDirectory}) {
|
|
660
|
-
if (!preset) {
|
|
661
|
-
throw new Error('No babel preset provided. Cannot configure babel transpilation');
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
await configFile.write({
|
|
665
|
-
path: projectRoot,
|
|
666
|
-
name: 'babel',
|
|
667
|
-
format: core.fileTypes.JSON,
|
|
668
|
-
config: {presets: [preset.name], ignore: [`./${buildDirectory}/`]}
|
|
669
|
-
});
|
|
670
|
-
|
|
671
|
-
return {
|
|
672
|
-
devDependencies: ['@babel/register', preset.packageName],
|
|
673
|
-
eslint: {}
|
|
674
|
-
};
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
async function scaffoldTypescript ({config, projectType, projectRoot, testFilenamePattern}) {
|
|
678
|
-
const eslintConfigs = ['typescript'];
|
|
679
|
-
const shareableTsConfigPackage = `${config.scope}/tsconfig`;
|
|
680
|
-
|
|
681
|
-
await fs.promises.writeFile(
|
|
682
|
-
`${projectRoot}/tsconfig.json`,
|
|
683
|
-
JSON.stringify({
|
|
684
|
-
$schema: 'https://json.schemastore.org/tsconfig',
|
|
685
|
-
extends: shareableTsConfigPackage,
|
|
686
|
-
compilerOptions: {
|
|
687
|
-
rootDir: 'src',
|
|
688
|
-
...javascriptCore.projectTypes.PACKAGE === projectType && {
|
|
689
|
-
outDir: 'lib',
|
|
690
|
-
declaration: true
|
|
691
|
-
}
|
|
692
|
-
},
|
|
693
|
-
include: ['src/**/*.ts'],
|
|
694
|
-
...testFilenamePattern && {exclude: [testFilenamePattern]}
|
|
695
|
-
})
|
|
696
|
-
);
|
|
697
|
-
|
|
698
|
-
return {
|
|
699
|
-
eslint: {configs: eslintConfigs},
|
|
700
|
-
eslintConfigs,
|
|
701
|
-
devDependencies: ['typescript', shareableTsConfigPackage],
|
|
702
|
-
vcsIgnore: {files: ['tsconfig.tsbuildinfo']}
|
|
703
|
-
};
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
function scaffoldDialect ({dialect, projectType, projectRoot, configs, buildDirectory, testFilenamePattern}) {
|
|
707
|
-
switch (dialect) {
|
|
708
|
-
case javascriptCore.dialects.BABEL:
|
|
709
|
-
return scaffoldBabel({preset: configs.babelPreset, projectRoot, buildDirectory});
|
|
710
|
-
case javascriptCore.dialects.TYPESCRIPT:
|
|
711
|
-
return scaffoldTypescript({config: configs.typescript, projectType, projectRoot, testFilenamePattern});
|
|
712
|
-
default:
|
|
713
|
-
return {};
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
|
|
717
752
|
function projectWillNotBeConsumed(projectType) {
|
|
718
753
|
return javascriptCore.projectTypes.APPLICATION === projectType || javascriptCore.projectTypes.CLI === projectType;
|
|
719
754
|
}
|
|
@@ -1167,6 +1202,7 @@ async function scaffoldProjectTypePlugin ({
|
|
|
1167
1202
|
packageName,
|
|
1168
1203
|
packageManager,
|
|
1169
1204
|
scope,
|
|
1205
|
+
dialect,
|
|
1170
1206
|
tests,
|
|
1171
1207
|
decisions,
|
|
1172
1208
|
plugins
|
|
@@ -1180,7 +1216,7 @@ async function scaffoldProjectTypePlugin ({
|
|
|
1180
1216
|
return javascriptCore.scaffoldChoice(
|
|
1181
1217
|
pluginsForProjectType,
|
|
1182
1218
|
chosenType,
|
|
1183
|
-
{projectRoot, projectName, packageName, packageManager, scope, tests}
|
|
1219
|
+
{projectRoot, projectName, packageName, packageManager, scope, tests, dialect}
|
|
1184
1220
|
);
|
|
1185
1221
|
}
|
|
1186
1222
|
|
|
@@ -1465,7 +1501,6 @@ async function scaffolder (options) {
|
|
|
1465
1501
|
configs,
|
|
1466
1502
|
projectRoot,
|
|
1467
1503
|
projectType,
|
|
1468
|
-
buildDirectory: projectTypeResults.buildDirectory,
|
|
1469
1504
|
testFilenamePattern: verificationResults.testFilenamePattern
|
|
1470
1505
|
}),
|
|
1471
1506
|
scaffoldCodeStyle({
|
|
@@ -1485,6 +1520,7 @@ async function scaffolder (options) {
|
|
|
1485
1520
|
packageName,
|
|
1486
1521
|
packageManager,
|
|
1487
1522
|
scope,
|
|
1523
|
+
dialect,
|
|
1488
1524
|
tests,
|
|
1489
1525
|
decisions,
|
|
1490
1526
|
plugins: {
|
|
@@ -1504,8 +1540,8 @@ async function scaffolder (options) {
|
|
|
1504
1540
|
javascriptCore.scaffoldChoice(ciServices, ci, {projectRoot, vcs, visibility, projectType, projectName, nodeVersion, tests}),
|
|
1505
1541
|
commitConventionPlugin.scaffold({projectRoot, projectType, configs, pathWithinParent})
|
|
1506
1542
|
])),
|
|
1507
|
-
projectTypePluginResults,
|
|
1508
1543
|
projectTypeResults,
|
|
1544
|
+
projectTypePluginResults,
|
|
1509
1545
|
verificationResults,
|
|
1510
1546
|
codeStyleResults,
|
|
1511
1547
|
npmResults,
|