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.cjs
CHANGED
|
@@ -1591,12 +1591,12 @@ module.exports = __toCommonJS(index_exports);
|
|
|
1591
1591
|
var import_commander = require("commander");
|
|
1592
1592
|
var import_chalk2 = __toESM(require_source(), 1);
|
|
1593
1593
|
var import_semver = __toESM(require("semver"), 1);
|
|
1594
|
-
var
|
|
1594
|
+
var import_core2 = require("@create-node-app/core");
|
|
1595
1595
|
|
|
1596
1596
|
// src/options.ts
|
|
1597
|
+
var import_core = require("@create-node-app/core");
|
|
1597
1598
|
var import_ci_info = require("ci-info");
|
|
1598
1599
|
var import_prompts = __toESM(require("prompts"), 1);
|
|
1599
|
-
var import_yargs = __toESM(require("yargs"), 1);
|
|
1600
1600
|
|
|
1601
1601
|
// src/templates.ts
|
|
1602
1602
|
var import_axios = __toESM(require("axios"), 1);
|
|
@@ -1681,9 +1681,6 @@ var getExtensionsGroupedByCategory = async (type, cliArgs) => {
|
|
|
1681
1681
|
};
|
|
1682
1682
|
|
|
1683
1683
|
// src/options.ts
|
|
1684
|
-
import_prompts.default.override(
|
|
1685
|
-
(0, import_yargs.default)(process.argv.slice(2)).help(false).version(false).argv
|
|
1686
|
-
);
|
|
1687
1684
|
var PACKAGE_MANAGERS = ["npm", "yarn", "pnpm"];
|
|
1688
1685
|
var isValidUrl = (url) => {
|
|
1689
1686
|
try {
|
|
@@ -1694,9 +1691,12 @@ var isValidUrl = (url) => {
|
|
|
1694
1691
|
}
|
|
1695
1692
|
};
|
|
1696
1693
|
var processNonInteractiveOptions = async (options) => {
|
|
1694
|
+
const setOverrides = options.setOverrides ?? {};
|
|
1695
|
+
delete options.setOverrides;
|
|
1697
1696
|
const categories = await getTemplateCategories();
|
|
1698
1697
|
let matchedTemplate;
|
|
1699
1698
|
const templatesOrExtensions = [];
|
|
1699
|
+
let resolvedTemplateUrl;
|
|
1700
1700
|
if (options.template && !isValidUrl(options.template)) {
|
|
1701
1701
|
const allTemplates = (await Promise.all(
|
|
1702
1702
|
categories.map((category) => getTemplatesForCategory(category))
|
|
@@ -1706,6 +1706,7 @@ var processNonInteractiveOptions = async (options) => {
|
|
|
1706
1706
|
);
|
|
1707
1707
|
if (matchedTemplate) {
|
|
1708
1708
|
templatesOrExtensions.push({ url: matchedTemplate.url });
|
|
1709
|
+
resolvedTemplateUrl = matchedTemplate.url;
|
|
1709
1710
|
if (matchedTemplate.customOptions) {
|
|
1710
1711
|
matchedTemplate.customOptions.forEach((customOption) => {
|
|
1711
1712
|
if (customOption.name && customOption.initial !== void 0) {
|
|
@@ -1720,7 +1721,19 @@ var processNonInteractiveOptions = async (options) => {
|
|
|
1720
1721
|
}
|
|
1721
1722
|
} else if (options.template) {
|
|
1722
1723
|
templatesOrExtensions.push({ url: options.template });
|
|
1724
|
+
resolvedTemplateUrl = options.template;
|
|
1723
1725
|
}
|
|
1726
|
+
if (resolvedTemplateUrl) {
|
|
1727
|
+
const cnaConfig = await (0, import_core.loadTemplateCnaConfig)(resolvedTemplateUrl);
|
|
1728
|
+
if (cnaConfig?.customOptions) {
|
|
1729
|
+
for (const opt of cnaConfig.customOptions) {
|
|
1730
|
+
if (opt.name && opt.initial !== void 0) {
|
|
1731
|
+
options[opt.name] = opt.initial;
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
Object.assign(options, setOverrides);
|
|
1724
1737
|
if (options.addons && Array.isArray(options.addons)) {
|
|
1725
1738
|
const extensionsGroupedByCategory = await getExtensionsGroupedByCategory([
|
|
1726
1739
|
matchedTemplate?.type || "custom",
|
|
@@ -1758,6 +1771,9 @@ var processNonInteractiveOptions = async (options) => {
|
|
|
1758
1771
|
return options;
|
|
1759
1772
|
};
|
|
1760
1773
|
var processInteractiveOptions = async (options) => {
|
|
1774
|
+
const { setOverrides = {}, ...restOptions } = options;
|
|
1775
|
+
options = restOptions;
|
|
1776
|
+
import_prompts.default.override({ ...options, ...setOverrides });
|
|
1761
1777
|
const categories = await getTemplateCategories();
|
|
1762
1778
|
const categoryDataPromises = categories.map(async (categorySlug) => {
|
|
1763
1779
|
const categoryData = await getCategoryData(categorySlug);
|
|
@@ -1844,7 +1860,11 @@ var processInteractiveOptions = async (options) => {
|
|
|
1844
1860
|
(template) => template.url === templateInput.template
|
|
1845
1861
|
);
|
|
1846
1862
|
const templateTemplateOrExtension = templateInput.template;
|
|
1847
|
-
const
|
|
1863
|
+
const cnaConfig = templateTemplateOrExtension ? await (0, import_core.loadTemplateCnaConfig)(templateTemplateOrExtension) : null;
|
|
1864
|
+
const rawCustomOptions = cnaConfig?.customOptions ?? existingTemplate?.customOptions ?? [];
|
|
1865
|
+
const customOptions = rawCustomOptions.map(
|
|
1866
|
+
(opt) => opt.name && Object.prototype.hasOwnProperty.call(setOverrides, opt.name) ? { ...opt, initial: setOverrides[opt.name] } : opt
|
|
1867
|
+
);
|
|
1848
1868
|
const appConfig = await (0, import_prompts.default)([
|
|
1849
1869
|
// The following prompts are placeholders for future inputs
|
|
1850
1870
|
{
|
|
@@ -1922,6 +1942,8 @@ var processInteractiveOptions = async (options) => {
|
|
|
1922
1942
|
...nextAppOptions.extend || []
|
|
1923
1943
|
].filter(Boolean).map((templateOrExtension) => ({ url: templateOrExtension }));
|
|
1924
1944
|
const nextOptions = { ...nextAppOptions, templatesOrExtensions };
|
|
1945
|
+
Object.assign(nextOptions, setOverrides);
|
|
1946
|
+
delete nextOptions.setOverrides;
|
|
1925
1947
|
if (nextAppOptions.verbose) {
|
|
1926
1948
|
console.log(JSON.stringify(nextOptions, null, 2));
|
|
1927
1949
|
}
|
|
@@ -1944,7 +1966,7 @@ var getCnaOptions = async (options) => {
|
|
|
1944
1966
|
// package.json
|
|
1945
1967
|
var package_default = {
|
|
1946
1968
|
name: "create-awesome-node-app",
|
|
1947
|
-
version: "0.
|
|
1969
|
+
version: "0.8.0",
|
|
1948
1970
|
type: "module",
|
|
1949
1971
|
description: "Command line tool to create Node apps with a lot of different templates and extensions.",
|
|
1950
1972
|
license: "MIT",
|
|
@@ -1998,21 +2020,19 @@ var package_default = {
|
|
|
1998
2020
|
"test:src": "npm run test"
|
|
1999
2021
|
},
|
|
2000
2022
|
dependencies: {
|
|
2001
|
-
"@create-node-app/core": "^0.
|
|
2023
|
+
"@create-node-app/core": "^0.6.0",
|
|
2002
2024
|
axios: "^1.13.6",
|
|
2003
2025
|
"ci-info": "^4.3.0",
|
|
2004
2026
|
commander: "^14.0.1",
|
|
2005
2027
|
prompts: "^2.4.2",
|
|
2006
|
-
semver: "^7.7.2"
|
|
2007
|
-
yargs: "^18.0.0"
|
|
2028
|
+
semver: "^7.7.2"
|
|
2008
2029
|
},
|
|
2009
2030
|
devDependencies: {
|
|
2010
|
-
"@create-node-app/core": "^0.
|
|
2031
|
+
"@create-node-app/core": "^0.6.0",
|
|
2011
2032
|
"@create-node-app/eslint-config-ts": "*",
|
|
2012
2033
|
"@types/node": "^24.5.2",
|
|
2013
2034
|
"@types/prompts": "^2.4.9",
|
|
2014
2035
|
"@types/semver": "^7.5.8",
|
|
2015
|
-
"@types/yargs": "^17.0.33",
|
|
2016
2036
|
eslint: "^9.35.0",
|
|
2017
2037
|
"eslint-config-turbo": "^2.5.6",
|
|
2018
2038
|
"eslint-plugin-turbo": "^2.5.6",
|
|
@@ -2118,13 +2138,16 @@ var main = async () => {
|
|
|
2118
2138
|
).option(
|
|
2119
2139
|
"--no-interactive",
|
|
2120
2140
|
"disable interactive mode (use only flags / non-interactive flow)"
|
|
2121
|
-
).option("--list-templates", "list all available templates").option("--list-addons", "list all available addons").
|
|
2141
|
+
).option("--list-templates", "list all available templates").option("--list-addons", "list all available addons").option(
|
|
2142
|
+
"--set <assignments...>",
|
|
2143
|
+
"set a custom template option (format: key=value, repeatable)"
|
|
2144
|
+
).action((providedProjectName) => {
|
|
2122
2145
|
projectName = providedProjectName || projectName;
|
|
2123
2146
|
});
|
|
2124
2147
|
program.parse(process.argv);
|
|
2125
2148
|
const opts = program.opts();
|
|
2126
|
-
(0,
|
|
2127
|
-
const latestVersion = await (0,
|
|
2149
|
+
(0, import_core2.checkNodeVersion)(package_default.engines.node, package_default.name);
|
|
2150
|
+
const latestVersion = await (0, import_core2.checkForLatestVersion)("create-awesome-node-app");
|
|
2128
2151
|
if (latestVersion && import_semver.default.lt(package_default.version, latestVersion)) {
|
|
2129
2152
|
console.log();
|
|
2130
2153
|
console.error(
|
|
@@ -2146,15 +2169,32 @@ We recommend always using the latest version of create-awesome-node-app if possi
|
|
|
2146
2169
|
});
|
|
2147
2170
|
return;
|
|
2148
2171
|
}
|
|
2149
|
-
const { useYarn, usePnpm, ...restOpts } = opts;
|
|
2172
|
+
const { useYarn, usePnpm, set, ...restOpts } = opts;
|
|
2150
2173
|
const packageManager = useYarn ? "yarn" : usePnpm ? "pnpm" : "npm";
|
|
2174
|
+
const setOverrides = {};
|
|
2175
|
+
if (Array.isArray(set)) {
|
|
2176
|
+
for (const assignment of set) {
|
|
2177
|
+
const eqIdx = assignment.indexOf("=");
|
|
2178
|
+
if (eqIdx > 0) {
|
|
2179
|
+
setOverrides[assignment.slice(0, eqIdx).trim()] = assignment.slice(
|
|
2180
|
+
eqIdx + 1
|
|
2181
|
+
);
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2151
2185
|
const templatesOrExtensions = [restOpts.template].concat(Array.isArray(restOpts.extend) ? restOpts.extend : []).filter(Boolean).reduce((acc, templateOrExtension) => {
|
|
2152
2186
|
if (!templateOrExtension) return acc;
|
|
2153
2187
|
return acc.concat({ url: templateOrExtension });
|
|
2154
2188
|
}, []);
|
|
2155
|
-
return (0,
|
|
2189
|
+
return (0, import_core2.createNodeApp)(
|
|
2156
2190
|
projectName,
|
|
2157
|
-
{
|
|
2191
|
+
{
|
|
2192
|
+
...restOpts,
|
|
2193
|
+
packageManager,
|
|
2194
|
+
templatesOrExtensions,
|
|
2195
|
+
projectName,
|
|
2196
|
+
setOverrides
|
|
2197
|
+
},
|
|
2158
2198
|
getCnaOptions
|
|
2159
2199
|
);
|
|
2160
2200
|
};
|