creatium 0.1.13 → 0.1.14

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/main.cjs CHANGED
@@ -1469,18 +1469,18 @@ class Core {
1469
1469
  async getCmds() {
1470
1470
  const res = {};
1471
1471
  const Klass = this.#getClass();
1472
- for (const [key, value] of Object.entries(this.config)) {
1472
+ await Promise.all(Object.entries(this.config).map(async ([key, value]) => {
1473
1473
  const {
1474
1474
  type,
1475
1475
  ...props
1476
1476
  } = value;
1477
- if (!(type in Klass)) continue;
1477
+ if (!(type in Klass)) return;
1478
1478
  const instance = new Klass[type](props);
1479
1479
  if ("cmd" in instance) {
1480
1480
  const cmd = await instance.cmd();
1481
1481
  if (cmd) res[key] = cmd;
1482
1482
  }
1483
- }
1483
+ }));
1484
1484
  return res;
1485
1485
  }
1486
1486
  async getPrompts(initialValues) {
@@ -1493,12 +1493,12 @@ class Core {
1493
1493
  ...cached,
1494
1494
  values: cachedValues
1495
1495
  } });
1496
- for (const [key, value] of Object.entries(this.config)) {
1496
+ await Promise.all(Object.entries(this.config).map(async ([key, value]) => {
1497
1497
  const {
1498
1498
  type,
1499
1499
  ...props
1500
1500
  } = value;
1501
- if (!(type in Klass)) continue;
1501
+ if (!(type in Klass)) return;
1502
1502
  const instance = new Klass[type](props);
1503
1503
  instance._onCancel = this.onCancel;
1504
1504
  instance.debugMode = this.debugMode;
@@ -1509,7 +1509,7 @@ class Core {
1509
1509
  instance.afterPrompt = async (value2) => await cached?.set({ [key]: value2 });
1510
1510
  if ("prompt" in instance)
1511
1511
  res[key] = await instance.getPromptHooked.bind(instance);
1512
- }
1512
+ }));
1513
1513
  return res;
1514
1514
  }
1515
1515
  }
@@ -1657,7 +1657,7 @@ class CreatiumCore {
1657
1657
  else if (typeof this.config.outro === "function" && this.#data)
1658
1658
  await this.config.outro(this.#data);
1659
1659
  else if (this.config.outro === void 0) {
1660
- this.utils.prompt.outro("Successfully completed \u{1F308}");
1660
+ this.utils.prompt.outro(this.utils.style.color.greenBright("Successfully completed \u{1F308}"));
1661
1661
  }
1662
1662
  }
1663
1663
  /**
@@ -1777,10 +1777,10 @@ class CreatiumCore {
1777
1777
  inputOpts
1778
1778
  } = {}) {
1779
1779
  if (!input) input = this.#cwd;
1780
- console.debug({ replacePlaceholdersData: {
1780
+ if (this.debugMode) console.dir({ replacePlaceholdersData: {
1781
1781
  params,
1782
1782
  input
1783
- } });
1783
+ } }, { depth: null });
1784
1784
  if (!params) return;
1785
1785
  const getContent = async (filePath) => {
1786
1786
  try {
@@ -1790,21 +1790,25 @@ class CreatiumCore {
1790
1790
  return void 0;
1791
1791
  }
1792
1792
  };
1793
- const paths = await getPaths(input, {
1793
+ const paths = (await getPaths("*", {
1794
1794
  filesOnly: true,
1795
+ cwd: input,
1795
1796
  dot: true,
1796
1797
  ...inputOpts || {}
1798
+ })).map((path) => joinPath(input, path));
1799
+ console.debug({
1800
+ templatePaths: paths,
1801
+ input
1797
1802
  });
1798
- console.debug({ templatePaths: paths });
1799
- for (const path of paths) {
1803
+ await Promise.all(paths.map(async (path) => {
1800
1804
  const content = await getContent(path);
1801
- if (!content) continue;
1805
+ if (!content) return;
1802
1806
  const res = await replacePlaceholders({
1803
1807
  content,
1804
1808
  params
1805
1809
  });
1806
1810
  await writeFile(path, res, "utf-8");
1807
- }
1811
+ }));
1808
1812
  }
1809
1813
  /**
1810
1814
  * Return the input path of a template by name or path.
package/dist/main.mjs CHANGED
@@ -1443,18 +1443,18 @@ class Core {
1443
1443
  async getCmds() {
1444
1444
  const res = {};
1445
1445
  const Klass = this.#getClass();
1446
- for (const [key, value] of Object.entries(this.config)) {
1446
+ await Promise.all(Object.entries(this.config).map(async ([key, value]) => {
1447
1447
  const {
1448
1448
  type,
1449
1449
  ...props
1450
1450
  } = value;
1451
- if (!(type in Klass)) continue;
1451
+ if (!(type in Klass)) return;
1452
1452
  const instance = new Klass[type](props);
1453
1453
  if ("cmd" in instance) {
1454
1454
  const cmd = await instance.cmd();
1455
1455
  if (cmd) res[key] = cmd;
1456
1456
  }
1457
- }
1457
+ }));
1458
1458
  return res;
1459
1459
  }
1460
1460
  async getPrompts(initialValues) {
@@ -1467,12 +1467,12 @@ class Core {
1467
1467
  ...cached,
1468
1468
  values: cachedValues
1469
1469
  } });
1470
- for (const [key, value] of Object.entries(this.config)) {
1470
+ await Promise.all(Object.entries(this.config).map(async ([key, value]) => {
1471
1471
  const {
1472
1472
  type,
1473
1473
  ...props
1474
1474
  } = value;
1475
- if (!(type in Klass)) continue;
1475
+ if (!(type in Klass)) return;
1476
1476
  const instance = new Klass[type](props);
1477
1477
  instance._onCancel = this.onCancel;
1478
1478
  instance.debugMode = this.debugMode;
@@ -1483,7 +1483,7 @@ class Core {
1483
1483
  instance.afterPrompt = async (value2) => await cached?.set({ [key]: value2 });
1484
1484
  if ("prompt" in instance)
1485
1485
  res[key] = await instance.getPromptHooked.bind(instance);
1486
- }
1486
+ }));
1487
1487
  return res;
1488
1488
  }
1489
1489
  }
@@ -1631,7 +1631,7 @@ class CreatiumCore {
1631
1631
  else if (typeof this.config.outro === "function" && this.#data)
1632
1632
  await this.config.outro(this.#data);
1633
1633
  else if (this.config.outro === void 0) {
1634
- this.utils.prompt.outro("Successfully completed \u{1F308}");
1634
+ this.utils.prompt.outro(this.utils.style.color.greenBright("Successfully completed \u{1F308}"));
1635
1635
  }
1636
1636
  }
1637
1637
  /**
@@ -1751,10 +1751,10 @@ class CreatiumCore {
1751
1751
  inputOpts
1752
1752
  } = {}) {
1753
1753
  if (!input) input = this.#cwd;
1754
- console.debug({ replacePlaceholdersData: {
1754
+ if (this.debugMode) console.dir({ replacePlaceholdersData: {
1755
1755
  params,
1756
1756
  input
1757
- } });
1757
+ } }, { depth: null });
1758
1758
  if (!params) return;
1759
1759
  const getContent = async (filePath) => {
1760
1760
  try {
@@ -1764,21 +1764,25 @@ class CreatiumCore {
1764
1764
  return void 0;
1765
1765
  }
1766
1766
  };
1767
- const paths = await getPaths(input, {
1767
+ const paths = (await getPaths("*", {
1768
1768
  filesOnly: true,
1769
+ cwd: input,
1769
1770
  dot: true,
1770
1771
  ...inputOpts || {}
1772
+ })).map((path) => joinPath(input, path));
1773
+ console.debug({
1774
+ templatePaths: paths,
1775
+ input
1771
1776
  });
1772
- console.debug({ templatePaths: paths });
1773
- for (const path of paths) {
1777
+ await Promise.all(paths.map(async (path) => {
1774
1778
  const content = await getContent(path);
1775
- if (!content) continue;
1779
+ if (!content) return;
1776
1780
  const res = await replacePlaceholders({
1777
1781
  content,
1778
1782
  params
1779
1783
  });
1780
1784
  await writeFile(path, res, "utf-8");
1781
- }
1785
+ }));
1782
1786
  }
1783
1787
  /**
1784
1788
  * Return the input path of a template by name or path.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "creatium",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Build your create-bins quickly and easily",
5
5
  "keywords": [
6
6
  "bin",
@@ -67,7 +67,7 @@
67
67
  "devDependencies": {
68
68
  "@types/columnify": "1.5.4",
69
69
  "@types/yargs": "17.0.33",
70
- "@creatium/repo-config": "0.1.13"
70
+ "@creatium/repo-config": "0.1.14"
71
71
  },
72
72
  "publishConfig": {
73
73
  "access": "public",