create-awesome-node-app 0.7.1 → 0.9.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.js CHANGED
@@ -970,9 +970,9 @@ var require_color_convert = __commonJS({
970
970
  }
971
971
  });
972
972
 
973
- // node_modules/ansi-styles/index.js
973
+ // ../../node_modules/chalk/node_modules/ansi-styles/index.js
974
974
  var require_ansi_styles = __commonJS({
975
- "node_modules/ansi-styles/index.js"(exports, module) {
975
+ "../../node_modules/chalk/node_modules/ansi-styles/index.js"(exports, module) {
976
976
  "use strict";
977
977
  var wrapAnsi16 = (fn, offset) => (...args) => {
978
978
  const code = fn(...args);
@@ -1227,9 +1227,9 @@ var require_supports_color = __commonJS({
1227
1227
  }
1228
1228
  });
1229
1229
 
1230
- // node_modules/chalk/source/util.js
1230
+ // ../../node_modules/chalk/source/util.js
1231
1231
  var require_util = __commonJS({
1232
- "node_modules/chalk/source/util.js"(exports, module) {
1232
+ "../../node_modules/chalk/source/util.js"(exports, module) {
1233
1233
  "use strict";
1234
1234
  var stringReplaceAll = (string, substring, replacer) => {
1235
1235
  let index = string.indexOf(substring);
@@ -1266,9 +1266,9 @@ var require_util = __commonJS({
1266
1266
  }
1267
1267
  });
1268
1268
 
1269
- // node_modules/chalk/source/templates.js
1269
+ // ../../node_modules/chalk/source/templates.js
1270
1270
  var require_templates = __commonJS({
1271
- "node_modules/chalk/source/templates.js"(exports, module) {
1271
+ "../../node_modules/chalk/source/templates.js"(exports, module) {
1272
1272
  "use strict";
1273
1273
  var TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
1274
1274
  var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
@@ -1380,9 +1380,9 @@ var require_templates = __commonJS({
1380
1380
  }
1381
1381
  });
1382
1382
 
1383
- // node_modules/chalk/source/index.js
1383
+ // ../../node_modules/chalk/source/index.js
1384
1384
  var require_source = __commonJS({
1385
- "node_modules/chalk/source/index.js"(exports, module) {
1385
+ "../../node_modules/chalk/source/index.js"(exports, module) {
1386
1386
  "use strict";
1387
1387
  var ansiStyles = require_ansi_styles();
1388
1388
  var { stdout: stdoutColor, stderr: stderrColor } = require_supports_color();
@@ -1569,13 +1569,10 @@ 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
- var PACKAGE_MANAGERS = ["npm", "yarn", "pnpm"];
1575
+ var PACKAGE_MANAGERS = ["npm", "yarn", "pnpm", "bun"];
1579
1576
  var isValidUrl = (url) => {
1580
1577
  try {
1581
1578
  new URL(url);
@@ -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 customOptions = existingTemplate?.customOptions || [];
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
  }
@@ -1832,10 +1854,41 @@ var getCnaOptions = async (options) => {
1832
1854
  return processNonInteractiveOptions(options);
1833
1855
  };
1834
1856
 
1857
+ // src/set-overrides.ts
1858
+ var unquoteSetValue = (value) => {
1859
+ if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
1860
+ return value.slice(1, -1);
1861
+ }
1862
+ return value;
1863
+ };
1864
+ var parseSetOverrides = (set) => {
1865
+ const setOverrides = {};
1866
+ if (!Array.isArray(set)) {
1867
+ return setOverrides;
1868
+ }
1869
+ const assignments = [];
1870
+ for (const part of set) {
1871
+ if (part.includes("=") || assignments.length === 0) {
1872
+ assignments.push(part);
1873
+ } else {
1874
+ assignments[assignments.length - 1] += ` ${part}`;
1875
+ }
1876
+ }
1877
+ for (const assignment of assignments) {
1878
+ const eqIdx = assignment.indexOf("=");
1879
+ if (eqIdx > 0) {
1880
+ setOverrides[assignment.slice(0, eqIdx).trim()] = unquoteSetValue(
1881
+ assignment.slice(eqIdx + 1).trim()
1882
+ );
1883
+ }
1884
+ }
1885
+ return setOverrides;
1886
+ };
1887
+
1835
1888
  // package.json
1836
1889
  var package_default = {
1837
1890
  name: "create-awesome-node-app",
1838
- version: "0.7.1",
1891
+ version: "0.9.0",
1839
1892
  type: "module",
1840
1893
  description: "Command line tool to create Node apps with a lot of different templates and extensions.",
1841
1894
  license: "MIT",
@@ -1889,27 +1942,22 @@ var package_default = {
1889
1942
  "test:src": "npm run test"
1890
1943
  },
1891
1944
  dependencies: {
1892
- "@create-node-app/core": "^0.5.7",
1893
- axios: "^1.13.6",
1945
+ "@create-node-app/core": "^0.6.0",
1946
+ axios: "^1.16.0",
1894
1947
  "ci-info": "^4.3.0",
1895
- commander: "^14.0.1",
1948
+ commander: "^14.0.3",
1896
1949
  prompts: "^2.4.2",
1897
- semver: "^7.7.2",
1898
- yargs: "^18.0.0"
1950
+ semver: "^7.7.4"
1899
1951
  },
1900
1952
  devDependencies: {
1901
- "@create-node-app/core": "^0.5.7",
1902
- "@create-node-app/eslint-config-ts": "*",
1903
- "@types/node": "^24.5.2",
1953
+ "@create-node-app/core": "^0.6.0",
1954
+ "@types/node": "^26.0.1",
1904
1955
  "@types/prompts": "^2.4.9",
1905
1956
  "@types/semver": "^7.5.8",
1906
- "@types/yargs": "^17.0.33",
1907
1957
  eslint: "^9.35.0",
1908
- "eslint-config-turbo": "^2.5.6",
1909
- "eslint-plugin-turbo": "^2.5.6",
1910
- nock: "^13.5.4",
1911
- tsup: "^8.5.0",
1912
- tsx: "^4.19.0"
1958
+ nock: "^14.0.15",
1959
+ tsup: "^8.5.1",
1960
+ tsx: "^4.22.4"
1913
1961
  }
1914
1962
  };
1915
1963
 
@@ -2002,14 +2050,17 @@ var main = async () => {
2002
2050
  ).option(
2003
2051
  "--addons [extensions...]",
2004
2052
  "specify extensions to apply for the boilerplate generation"
2005
- ).option("--use-yarn", "use yarn instead of npm or pnpm").option("--use-pnpm", "use pnpm instead of yarn or npm").option(
2053
+ ).option("--use-yarn", "use yarn instead of npm or pnpm or bun").option("--use-pnpm", "use pnpm instead of yarn, npm, or bun").option("--use-bun", "use bun instead of npm, yarn, or pnpm").option(
2006
2054
  "--interactive",
2007
2055
  "force interactive mode (default outside CI unless --no-interactive)",
2008
2056
  void 0
2009
2057
  ).option(
2010
2058
  "--no-interactive",
2011
2059
  "disable interactive mode (use only flags / non-interactive flow)"
2012
- ).option("--list-templates", "list all available templates").option("--list-addons", "list all available addons").action((providedProjectName) => {
2060
+ ).option("--list-templates", "list all available templates").option("--list-addons", "list all available addons").option(
2061
+ "--set <assignments...>",
2062
+ "set a custom template option (format: key=value; quote values with spaces: --set 'projectName=My App' or --set 'projectName=My App' --set 'author=Jane Doe')"
2063
+ ).action((providedProjectName) => {
2013
2064
  projectName = providedProjectName || projectName;
2014
2065
  });
2015
2066
  program.parse(process.argv);
@@ -2037,15 +2088,22 @@ We recommend always using the latest version of create-awesome-node-app if possi
2037
2088
  });
2038
2089
  return;
2039
2090
  }
2040
- const { useYarn, usePnpm, ...restOpts } = opts;
2041
- const packageManager = useYarn ? "yarn" : usePnpm ? "pnpm" : "npm";
2091
+ const { useYarn, usePnpm, useBun, set, ...restOpts } = opts;
2092
+ const packageManager = useYarn ? "yarn" : usePnpm ? "pnpm" : useBun ? "bun" : "npm";
2093
+ const setOverrides = parseSetOverrides(set);
2042
2094
  const templatesOrExtensions = [restOpts.template].concat(Array.isArray(restOpts.extend) ? restOpts.extend : []).filter(Boolean).reduce((acc, templateOrExtension) => {
2043
2095
  if (!templateOrExtension) return acc;
2044
2096
  return acc.concat({ url: templateOrExtension });
2045
2097
  }, []);
2046
2098
  return createNodeApp(
2047
2099
  projectName,
2048
- { ...restOpts, packageManager, templatesOrExtensions, projectName },
2100
+ {
2101
+ ...restOpts,
2102
+ packageManager,
2103
+ templatesOrExtensions,
2104
+ projectName,
2105
+ setOverrides
2106
+ },
2049
2107
  getCnaOptions
2050
2108
  );
2051
2109
  };