create-awesome-node-app 0.7.1 → 0.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/dist/index.cjs +58 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +54 -14
- package/dist/index.js.map +1 -1
- package/package.json +4 -6
package/dist/index.js
CHANGED
|
@@ -1569,12 +1569,9 @@ import {
|
|
|
1569
1569
|
} from "@create-node-app/core";
|
|
1570
1570
|
|
|
1571
1571
|
// src/options.ts
|
|
1572
|
+
import { loadTemplateCnaConfig } from "@create-node-app/core";
|
|
1572
1573
|
import { isCI } from "ci-info";
|
|
1573
1574
|
import prompts from "prompts";
|
|
1574
|
-
import yargs from "yargs";
|
|
1575
|
-
prompts.override(
|
|
1576
|
-
yargs(process.argv.slice(2)).help(false).version(false).argv
|
|
1577
|
-
);
|
|
1578
1575
|
var PACKAGE_MANAGERS = ["npm", "yarn", "pnpm"];
|
|
1579
1576
|
var isValidUrl = (url) => {
|
|
1580
1577
|
try {
|
|
@@ -1585,9 +1582,12 @@ var isValidUrl = (url) => {
|
|
|
1585
1582
|
}
|
|
1586
1583
|
};
|
|
1587
1584
|
var processNonInteractiveOptions = async (options) => {
|
|
1585
|
+
const setOverrides = options.setOverrides ?? {};
|
|
1586
|
+
delete options.setOverrides;
|
|
1588
1587
|
const categories = await getTemplateCategories();
|
|
1589
1588
|
let matchedTemplate;
|
|
1590
1589
|
const templatesOrExtensions = [];
|
|
1590
|
+
let resolvedTemplateUrl;
|
|
1591
1591
|
if (options.template && !isValidUrl(options.template)) {
|
|
1592
1592
|
const allTemplates = (await Promise.all(
|
|
1593
1593
|
categories.map((category) => getTemplatesForCategory(category))
|
|
@@ -1597,6 +1597,7 @@ var processNonInteractiveOptions = async (options) => {
|
|
|
1597
1597
|
);
|
|
1598
1598
|
if (matchedTemplate) {
|
|
1599
1599
|
templatesOrExtensions.push({ url: matchedTemplate.url });
|
|
1600
|
+
resolvedTemplateUrl = matchedTemplate.url;
|
|
1600
1601
|
if (matchedTemplate.customOptions) {
|
|
1601
1602
|
matchedTemplate.customOptions.forEach((customOption) => {
|
|
1602
1603
|
if (customOption.name && customOption.initial !== void 0) {
|
|
@@ -1611,7 +1612,19 @@ var processNonInteractiveOptions = async (options) => {
|
|
|
1611
1612
|
}
|
|
1612
1613
|
} else if (options.template) {
|
|
1613
1614
|
templatesOrExtensions.push({ url: options.template });
|
|
1615
|
+
resolvedTemplateUrl = options.template;
|
|
1614
1616
|
}
|
|
1617
|
+
if (resolvedTemplateUrl) {
|
|
1618
|
+
const cnaConfig = await loadTemplateCnaConfig(resolvedTemplateUrl);
|
|
1619
|
+
if (cnaConfig?.customOptions) {
|
|
1620
|
+
for (const opt of cnaConfig.customOptions) {
|
|
1621
|
+
if (opt.name && opt.initial !== void 0) {
|
|
1622
|
+
options[opt.name] = opt.initial;
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
Object.assign(options, setOverrides);
|
|
1615
1628
|
if (options.addons && Array.isArray(options.addons)) {
|
|
1616
1629
|
const extensionsGroupedByCategory = await getExtensionsGroupedByCategory([
|
|
1617
1630
|
matchedTemplate?.type || "custom",
|
|
@@ -1649,6 +1662,9 @@ var processNonInteractiveOptions = async (options) => {
|
|
|
1649
1662
|
return options;
|
|
1650
1663
|
};
|
|
1651
1664
|
var processInteractiveOptions = async (options) => {
|
|
1665
|
+
const { setOverrides = {}, ...restOptions } = options;
|
|
1666
|
+
options = restOptions;
|
|
1667
|
+
prompts.override({ ...options, ...setOverrides });
|
|
1652
1668
|
const categories = await getTemplateCategories();
|
|
1653
1669
|
const categoryDataPromises = categories.map(async (categorySlug) => {
|
|
1654
1670
|
const categoryData = await getCategoryData(categorySlug);
|
|
@@ -1735,7 +1751,11 @@ var processInteractiveOptions = async (options) => {
|
|
|
1735
1751
|
(template) => template.url === templateInput.template
|
|
1736
1752
|
);
|
|
1737
1753
|
const templateTemplateOrExtension = templateInput.template;
|
|
1738
|
-
const
|
|
1754
|
+
const cnaConfig = templateTemplateOrExtension ? await loadTemplateCnaConfig(templateTemplateOrExtension) : null;
|
|
1755
|
+
const rawCustomOptions = cnaConfig?.customOptions ?? existingTemplate?.customOptions ?? [];
|
|
1756
|
+
const customOptions = rawCustomOptions.map(
|
|
1757
|
+
(opt) => opt.name && Object.prototype.hasOwnProperty.call(setOverrides, opt.name) ? { ...opt, initial: setOverrides[opt.name] } : opt
|
|
1758
|
+
);
|
|
1739
1759
|
const appConfig = await prompts([
|
|
1740
1760
|
// The following prompts are placeholders for future inputs
|
|
1741
1761
|
{
|
|
@@ -1813,6 +1833,8 @@ var processInteractiveOptions = async (options) => {
|
|
|
1813
1833
|
...nextAppOptions.extend || []
|
|
1814
1834
|
].filter(Boolean).map((templateOrExtension) => ({ url: templateOrExtension }));
|
|
1815
1835
|
const nextOptions = { ...nextAppOptions, templatesOrExtensions };
|
|
1836
|
+
Object.assign(nextOptions, setOverrides);
|
|
1837
|
+
delete nextOptions.setOverrides;
|
|
1816
1838
|
if (nextAppOptions.verbose) {
|
|
1817
1839
|
console.log(JSON.stringify(nextOptions, null, 2));
|
|
1818
1840
|
}
|
|
@@ -1835,7 +1857,7 @@ var getCnaOptions = async (options) => {
|
|
|
1835
1857
|
// package.json
|
|
1836
1858
|
var package_default = {
|
|
1837
1859
|
name: "create-awesome-node-app",
|
|
1838
|
-
version: "0.
|
|
1860
|
+
version: "0.8.0",
|
|
1839
1861
|
type: "module",
|
|
1840
1862
|
description: "Command line tool to create Node apps with a lot of different templates and extensions.",
|
|
1841
1863
|
license: "MIT",
|
|
@@ -1889,21 +1911,19 @@ var package_default = {
|
|
|
1889
1911
|
"test:src": "npm run test"
|
|
1890
1912
|
},
|
|
1891
1913
|
dependencies: {
|
|
1892
|
-
"@create-node-app/core": "^0.
|
|
1914
|
+
"@create-node-app/core": "^0.6.0",
|
|
1893
1915
|
axios: "^1.13.6",
|
|
1894
1916
|
"ci-info": "^4.3.0",
|
|
1895
1917
|
commander: "^14.0.1",
|
|
1896
1918
|
prompts: "^2.4.2",
|
|
1897
|
-
semver: "^7.7.2"
|
|
1898
|
-
yargs: "^18.0.0"
|
|
1919
|
+
semver: "^7.7.2"
|
|
1899
1920
|
},
|
|
1900
1921
|
devDependencies: {
|
|
1901
|
-
"@create-node-app/core": "^0.
|
|
1922
|
+
"@create-node-app/core": "^0.6.0",
|
|
1902
1923
|
"@create-node-app/eslint-config-ts": "*",
|
|
1903
1924
|
"@types/node": "^24.5.2",
|
|
1904
1925
|
"@types/prompts": "^2.4.9",
|
|
1905
1926
|
"@types/semver": "^7.5.8",
|
|
1906
|
-
"@types/yargs": "^17.0.33",
|
|
1907
1927
|
eslint: "^9.35.0",
|
|
1908
1928
|
"eslint-config-turbo": "^2.5.6",
|
|
1909
1929
|
"eslint-plugin-turbo": "^2.5.6",
|
|
@@ -2009,7 +2029,10 @@ var main = async () => {
|
|
|
2009
2029
|
).option(
|
|
2010
2030
|
"--no-interactive",
|
|
2011
2031
|
"disable interactive mode (use only flags / non-interactive flow)"
|
|
2012
|
-
).option("--list-templates", "list all available templates").option("--list-addons", "list all available addons").
|
|
2032
|
+
).option("--list-templates", "list all available templates").option("--list-addons", "list all available addons").option(
|
|
2033
|
+
"--set <assignments...>",
|
|
2034
|
+
"set a custom template option (format: key=value, repeatable)"
|
|
2035
|
+
).action((providedProjectName) => {
|
|
2013
2036
|
projectName = providedProjectName || projectName;
|
|
2014
2037
|
});
|
|
2015
2038
|
program.parse(process.argv);
|
|
@@ -2037,15 +2060,32 @@ We recommend always using the latest version of create-awesome-node-app if possi
|
|
|
2037
2060
|
});
|
|
2038
2061
|
return;
|
|
2039
2062
|
}
|
|
2040
|
-
const { useYarn, usePnpm, ...restOpts } = opts;
|
|
2063
|
+
const { useYarn, usePnpm, set, ...restOpts } = opts;
|
|
2041
2064
|
const packageManager = useYarn ? "yarn" : usePnpm ? "pnpm" : "npm";
|
|
2065
|
+
const setOverrides = {};
|
|
2066
|
+
if (Array.isArray(set)) {
|
|
2067
|
+
for (const assignment of set) {
|
|
2068
|
+
const eqIdx = assignment.indexOf("=");
|
|
2069
|
+
if (eqIdx > 0) {
|
|
2070
|
+
setOverrides[assignment.slice(0, eqIdx).trim()] = assignment.slice(
|
|
2071
|
+
eqIdx + 1
|
|
2072
|
+
);
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2042
2076
|
const templatesOrExtensions = [restOpts.template].concat(Array.isArray(restOpts.extend) ? restOpts.extend : []).filter(Boolean).reduce((acc, templateOrExtension) => {
|
|
2043
2077
|
if (!templateOrExtension) return acc;
|
|
2044
2078
|
return acc.concat({ url: templateOrExtension });
|
|
2045
2079
|
}, []);
|
|
2046
2080
|
return createNodeApp(
|
|
2047
2081
|
projectName,
|
|
2048
|
-
{
|
|
2082
|
+
{
|
|
2083
|
+
...restOpts,
|
|
2084
|
+
packageManager,
|
|
2085
|
+
templatesOrExtensions,
|
|
2086
|
+
projectName,
|
|
2087
|
+
setOverrides
|
|
2088
|
+
},
|
|
2049
2089
|
getCnaOptions
|
|
2050
2090
|
);
|
|
2051
2091
|
};
|