@form8ion/javascript 5.7.0 → 5.8.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 +135 -102
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.es.js +139 -106
- package/lib/index.es.js.map +1 -1
- package/package.json +3 -3
package/lib/index.es.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { questionNames as questionNames$2, questions } from '@travi/language-scaffolder-prompts';
|
|
2
2
|
import deepmerge from 'deepmerge';
|
|
3
|
-
import { validateOptions, scaffoldChoice, installDependencies, PROD_DEPENDENCY_TYPE, DEV_DEPENDENCY_TYPE, packageManagers
|
|
3
|
+
import { validateOptions, scaffoldChoice, dialects, projectTypes, installDependencies, PROD_DEPENDENCY_TYPE, DEV_DEPENDENCY_TYPE, packageManagers } from '@form8ion/javascript-core';
|
|
4
4
|
import * as joi from 'joi';
|
|
5
5
|
import { Separator } from 'inquirer';
|
|
6
6
|
import { prompt as prompt$1 } from '@form8ion/overridable-prompts';
|
|
7
7
|
import { scaffold, lift as lift$3 } from '@form8ion/codecov';
|
|
8
8
|
import { promises } from 'fs';
|
|
9
|
-
import { fileExists,
|
|
9
|
+
import { fileExists, writeConfigFile, fileTypes, applyEnhancers } from '@form8ion/core';
|
|
10
10
|
import { info, error, warn } from '@travi/cli-messages';
|
|
11
11
|
import * as commitConventionPlugin from '@form8ion/commit-convention';
|
|
12
12
|
import { scaffold as scaffold$4 } from '@form8ion/commit-convention';
|
|
@@ -24,7 +24,7 @@ import { resolve } from 'path';
|
|
|
24
24
|
import * as huskyPlugin from '@form8ion/husky';
|
|
25
25
|
import { scaffold as scaffold$3 } from '@form8ion/husky';
|
|
26
26
|
import { lift as lift$4, scaffold as scaffold$2 } from '@form8ion/eslint';
|
|
27
|
-
import { write } from '@form8ion/config-file';
|
|
27
|
+
import { write as write$1 } from '@form8ion/config-file';
|
|
28
28
|
|
|
29
29
|
function ownKeys(object, enumerableOnly) {
|
|
30
30
|
var keys = Object.keys(object);
|
|
@@ -284,6 +284,109 @@ var enginesEnhancer = /*#__PURE__*/Object.freeze({
|
|
|
284
284
|
lift: lift$1
|
|
285
285
|
});
|
|
286
286
|
|
|
287
|
+
function write({
|
|
288
|
+
projectRoot,
|
|
289
|
+
config
|
|
290
|
+
}) {
|
|
291
|
+
return writeConfigFile({
|
|
292
|
+
format: fileTypes.JSON,
|
|
293
|
+
name: 'package',
|
|
294
|
+
path: projectRoot,
|
|
295
|
+
config
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function projectWillBeTested(scripts) {
|
|
300
|
+
return Object.keys(scripts).find(scriptName => scriptName.startsWith('test:'));
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function projectShouldBeBuiltForVerification(scripts) {
|
|
304
|
+
return 'run-s build' === scripts['pregenerate:md'];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function defineScripts(scripts) {
|
|
308
|
+
return {
|
|
309
|
+
test: `npm-run-all --print-label${projectShouldBeBuiltForVerification(scripts) ? ' build' : ''} --parallel lint:*${projectWillBeTested(scripts) ? ' --parallel test:*' : ''}`
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function defineVcsHostDetails(vcs, packageType, packageName, pathWithinParent) {
|
|
314
|
+
return vcs && 'github' === vcs.host && {
|
|
315
|
+
repository: pathWithinParent ? {
|
|
316
|
+
type: 'git',
|
|
317
|
+
url: `https://github.com/${vcs.owner}/${vcs.name}.git`,
|
|
318
|
+
directory: pathWithinParent
|
|
319
|
+
} : `${vcs.owner}/${vcs.name}`,
|
|
320
|
+
bugs: `https://github.com/${vcs.owner}/${vcs.name}/issues`,
|
|
321
|
+
homepage: projectTypes.PACKAGE === packageType ? `https://npm.im/${packageName}` : `https://github.com/${vcs.owner}/${vcs.name}#readme`
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function buildPackageDetails ({
|
|
326
|
+
packageName,
|
|
327
|
+
projectType,
|
|
328
|
+
dialect,
|
|
329
|
+
license,
|
|
330
|
+
vcs,
|
|
331
|
+
author,
|
|
332
|
+
description,
|
|
333
|
+
scripts,
|
|
334
|
+
packageProperties,
|
|
335
|
+
pathWithinParent
|
|
336
|
+
}) {
|
|
337
|
+
return _objectSpread2(_objectSpread2(_objectSpread2({
|
|
338
|
+
name: packageName,
|
|
339
|
+
description,
|
|
340
|
+
license,
|
|
341
|
+
type: dialects.ESM === dialect ? 'module' : 'commonjs'
|
|
342
|
+
}, packageProperties), defineVcsHostDetails(vcs, projectType, packageName, pathWithinParent)), {}, {
|
|
343
|
+
author: `${author.name}${author.email ? ` <${author.email}>` : ''}${author.url ? ` (${author.url})` : ''}`,
|
|
344
|
+
scripts: defineScripts(scripts)
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
async function scaffoldPackage ({
|
|
349
|
+
projectRoot,
|
|
350
|
+
projectType,
|
|
351
|
+
dialect,
|
|
352
|
+
scripts,
|
|
353
|
+
packageName,
|
|
354
|
+
license,
|
|
355
|
+
vcs,
|
|
356
|
+
author,
|
|
357
|
+
description,
|
|
358
|
+
packageProperties,
|
|
359
|
+
pathWithinParent
|
|
360
|
+
}) {
|
|
361
|
+
info('Configuring package.json');
|
|
362
|
+
const packageData = await buildPackageDetails({
|
|
363
|
+
packageName,
|
|
364
|
+
projectType,
|
|
365
|
+
dialect,
|
|
366
|
+
license,
|
|
367
|
+
vcs,
|
|
368
|
+
author,
|
|
369
|
+
description,
|
|
370
|
+
scripts,
|
|
371
|
+
packageProperties,
|
|
372
|
+
pathWithinParent
|
|
373
|
+
});
|
|
374
|
+
await write({
|
|
375
|
+
projectRoot,
|
|
376
|
+
config: packageData
|
|
377
|
+
});
|
|
378
|
+
return {
|
|
379
|
+
homepage: packageData.homepage
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function liftScripts ({
|
|
384
|
+
existingScripts,
|
|
385
|
+
scripts
|
|
386
|
+
}) {
|
|
387
|
+
return _objectSpread2(_objectSpread2({}, existingScripts), scripts);
|
|
388
|
+
}
|
|
389
|
+
|
|
287
390
|
async function liftPackage ({
|
|
288
391
|
projectRoot,
|
|
289
392
|
scripts,
|
|
@@ -298,11 +401,17 @@ async function liftPackage ({
|
|
|
298
401
|
});
|
|
299
402
|
const pathToPackageJson = `${projectRoot}/package.json`;
|
|
300
403
|
const existingPackageJsonContents = JSON.parse(await promises.readFile(pathToPackageJson, 'utf8'));
|
|
301
|
-
await
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
404
|
+
await write({
|
|
405
|
+
projectRoot,
|
|
406
|
+
config: _objectSpread2(_objectSpread2({}, existingPackageJsonContents), {}, {
|
|
407
|
+
scripts: liftScripts({
|
|
408
|
+
existingScripts: existingPackageJsonContents.scripts,
|
|
409
|
+
scripts
|
|
410
|
+
})
|
|
411
|
+
}, tags && {
|
|
412
|
+
keywords: existingPackageJsonContents.keywords ? [...existingPackageJsonContents.keywords, ...tags] : tags
|
|
413
|
+
})
|
|
414
|
+
});
|
|
306
415
|
}
|
|
307
416
|
|
|
308
417
|
info('Installing dependencies');
|
|
@@ -664,7 +773,7 @@ async function scaffoldBabel ({
|
|
|
664
773
|
throw new Error('No babel preset provided. Cannot configure babel transpilation');
|
|
665
774
|
}
|
|
666
775
|
|
|
667
|
-
await write({
|
|
776
|
+
await write$1({
|
|
668
777
|
path: projectRoot,
|
|
669
778
|
name: 'babel',
|
|
670
779
|
format: fileTypes.JSON,
|
|
@@ -856,87 +965,6 @@ function buildVcsIgnoreLists (vcsIgnoreLists = {}) {
|
|
|
856
965
|
};
|
|
857
966
|
}
|
|
858
967
|
|
|
859
|
-
function projectWillBeTested(scripts) {
|
|
860
|
-
return Object.keys(scripts).find(scriptName => scriptName.startsWith('test:'));
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
function projectShouldBeBuiltForVerification(scripts) {
|
|
864
|
-
return 'run-s build' === scripts['pregenerate:md'];
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
function defineScripts(scripts) {
|
|
868
|
-
return {
|
|
869
|
-
test: `npm-run-all --print-label${projectShouldBeBuiltForVerification(scripts) ? ' build' : ''} --parallel lint:*${projectWillBeTested(scripts) ? ' --parallel test:*' : ''}`
|
|
870
|
-
};
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
function defineVcsHostDetails(vcs, packageType, packageName, pathWithinParent) {
|
|
874
|
-
return vcs && 'github' === vcs.host && {
|
|
875
|
-
repository: pathWithinParent ? {
|
|
876
|
-
type: 'git',
|
|
877
|
-
url: `https://github.com/${vcs.owner}/${vcs.name}.git`,
|
|
878
|
-
directory: pathWithinParent
|
|
879
|
-
} : `${vcs.owner}/${vcs.name}`,
|
|
880
|
-
bugs: `https://github.com/${vcs.owner}/${vcs.name}/issues`,
|
|
881
|
-
homepage: projectTypes.PACKAGE === packageType ? `https://npm.im/${packageName}` : `https://github.com/${vcs.owner}/${vcs.name}#readme`
|
|
882
|
-
};
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
function buildPackageDetails ({
|
|
886
|
-
packageName,
|
|
887
|
-
projectType,
|
|
888
|
-
dialect,
|
|
889
|
-
license,
|
|
890
|
-
vcs,
|
|
891
|
-
author,
|
|
892
|
-
description,
|
|
893
|
-
scripts,
|
|
894
|
-
packageProperties,
|
|
895
|
-
pathWithinParent
|
|
896
|
-
}) {
|
|
897
|
-
return _objectSpread2(_objectSpread2(_objectSpread2({
|
|
898
|
-
name: packageName,
|
|
899
|
-
description,
|
|
900
|
-
license,
|
|
901
|
-
type: dialects.ESM === dialect ? 'module' : 'commonjs'
|
|
902
|
-
}, packageProperties), defineVcsHostDetails(vcs, projectType, packageName, pathWithinParent)), {}, {
|
|
903
|
-
author: `${author.name}${author.email ? ` <${author.email}>` : ''}${author.url ? ` (${author.url})` : ''}`,
|
|
904
|
-
scripts: defineScripts(scripts)
|
|
905
|
-
});
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
async function scaffoldPackage ({
|
|
909
|
-
projectRoot,
|
|
910
|
-
projectType,
|
|
911
|
-
dialect,
|
|
912
|
-
scripts,
|
|
913
|
-
packageName,
|
|
914
|
-
license,
|
|
915
|
-
vcs,
|
|
916
|
-
author,
|
|
917
|
-
description,
|
|
918
|
-
packageProperties,
|
|
919
|
-
pathWithinParent
|
|
920
|
-
}) {
|
|
921
|
-
info('Configuring package.json');
|
|
922
|
-
const packageData = await buildPackageDetails({
|
|
923
|
-
packageName,
|
|
924
|
-
projectType,
|
|
925
|
-
dialect,
|
|
926
|
-
license,
|
|
927
|
-
vcs,
|
|
928
|
-
author,
|
|
929
|
-
description,
|
|
930
|
-
scripts,
|
|
931
|
-
packageProperties,
|
|
932
|
-
pathWithinParent
|
|
933
|
-
});
|
|
934
|
-
await promises.writeFile(`${projectRoot}/package.json`, JSON.stringify(packageData));
|
|
935
|
-
return {
|
|
936
|
-
homepage: packageData.homepage
|
|
937
|
-
};
|
|
938
|
-
}
|
|
939
|
-
|
|
940
968
|
function buildPackageName (projectName, scope) {
|
|
941
969
|
const name = `${scope ? `@${scope}/` : ''}${projectName}`;
|
|
942
970
|
const {
|
|
@@ -1437,22 +1465,27 @@ async function scaffoldRemark ({
|
|
|
1437
1465
|
vcs,
|
|
1438
1466
|
dialect
|
|
1439
1467
|
}) {
|
|
1440
|
-
await
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1468
|
+
await write$1({
|
|
1469
|
+
format: fileTypes.JSON,
|
|
1470
|
+
path: projectRoot,
|
|
1471
|
+
name: 'remark',
|
|
1472
|
+
config: {
|
|
1473
|
+
settings: {
|
|
1474
|
+
listItemIndent: 1,
|
|
1475
|
+
emphasis: '_',
|
|
1476
|
+
strong: '_',
|
|
1477
|
+
bullet: '*',
|
|
1478
|
+
incrementListMarker: false
|
|
1479
|
+
},
|
|
1480
|
+
plugins: [config, ['remark-toc', {
|
|
1481
|
+
tight: true
|
|
1482
|
+
}], ...(projectTypes.PACKAGE === projectType ? [['remark-usage', {
|
|
1483
|
+
heading: 'example'
|
|
1484
|
+
}]] : []), ...(!vcs ? [['validate-links', {
|
|
1485
|
+
repository: false
|
|
1486
|
+
}]] : [])]
|
|
1487
|
+
}
|
|
1488
|
+
});
|
|
1456
1489
|
return deepmerge({
|
|
1457
1490
|
devDependencies: [config, 'remark-cli', 'remark-toc'],
|
|
1458
1491
|
scripts: {
|