@batijs/cli 0.0.226 → 0.0.227
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.
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
// files/$README.md.ts
|
|
2
|
-
import { loadReadme } from "@batijs/core";
|
|
2
|
+
import { getArgs, getVersion, loadReadme, markdown } from "@batijs/core";
|
|
3
3
|
async function getReadme(props) {
|
|
4
4
|
const content = await loadReadme(props);
|
|
5
5
|
const flags = Array.from(props.meta.BATI).filter((f) => f !== "force").map((f) => `--${f}`).join(" ");
|
|
6
|
-
const
|
|
6
|
+
const v = getVersion();
|
|
7
|
+
const intro = `Generated with [Bati](https://batijs.dev) ${v ? `(${markdown.link("https://www.npmjs.com/package/@batijs/create-app/v/" + v.version, "version " + v.semver.at(-1))})` : ""} using this command:
|
|
8
|
+
|
|
9
|
+
\`\`\`sh
|
|
10
|
+
${getArgs()} ${flags}
|
|
11
|
+
\`\`\`
|
|
12
|
+
`;
|
|
7
13
|
content.addIntro(intro);
|
|
8
14
|
return content.finalize();
|
|
9
15
|
}
|
|
@@ -1,29 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
2
|
|
|
28
3
|
// ../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/core.mjs
|
|
29
4
|
var LogLevels = {
|
|
@@ -1062,7 +1037,7 @@ function createConsola2(options = {}) {
|
|
|
1062
1037
|
defaults: { level },
|
|
1063
1038
|
stdout: process.stdout,
|
|
1064
1039
|
stderr: process.stderr,
|
|
1065
|
-
prompt: (...args) => import("./prompt-
|
|
1040
|
+
prompt: (...args) => import("./prompt-SUR66HP4.js").then((m) => m.prompt(...args)),
|
|
1066
1041
|
reporters: options.reporters || [
|
|
1067
1042
|
options.fancy ?? !(isCI2 || isTest) ? new FancyReporter() : new BasicReporter()
|
|
1068
1043
|
],
|
|
@@ -1082,8 +1057,6 @@ function _getDefaultLogLevel() {
|
|
|
1082
1057
|
var consola = createConsola2();
|
|
1083
1058
|
|
|
1084
1059
|
export {
|
|
1085
|
-
__commonJS,
|
|
1086
|
-
__toESM,
|
|
1087
1060
|
colors,
|
|
1088
1061
|
getDefaultExportFromCjs,
|
|
1089
1062
|
isUnicodeSupported,
|
package/dist/index.js
CHANGED
|
@@ -1,35 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
__commonJS,
|
|
4
|
-
__toESM,
|
|
5
3
|
colors,
|
|
6
4
|
consola
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
|
|
9
|
-
// ../../node_modules/.pnpm/which-pm-runs@1.1.0/node_modules/which-pm-runs/index.js
|
|
10
|
-
var require_which_pm_runs = __commonJS({
|
|
11
|
-
"../../node_modules/.pnpm/which-pm-runs@1.1.0/node_modules/which-pm-runs/index.js"(exports, module) {
|
|
12
|
-
"use strict";
|
|
13
|
-
module.exports = function() {
|
|
14
|
-
if (!process.env.npm_config_user_agent) {
|
|
15
|
-
return void 0;
|
|
16
|
-
}
|
|
17
|
-
return pmFromUserAgent(process.env.npm_config_user_agent);
|
|
18
|
-
};
|
|
19
|
-
function pmFromUserAgent(userAgent) {
|
|
20
|
-
const pmSpec = userAgent.split(" ")[0];
|
|
21
|
-
const separatorPos = pmSpec.lastIndexOf("/");
|
|
22
|
-
const name = pmSpec.substring(0, separatorPos);
|
|
23
|
-
return {
|
|
24
|
-
name: name === "npminstall" ? "cnpm" : name,
|
|
25
|
-
version: pmSpec.substring(separatorPos + 1)
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
});
|
|
5
|
+
} from "./chunk-MFJ4ET44.js";
|
|
30
6
|
|
|
31
7
|
// index.ts
|
|
32
8
|
import { existsSync as existsSync2 } from "fs";
|
|
9
|
+
import { exec as nodeExec } from "child_process";
|
|
33
10
|
import { access, constants, lstat, readdir, readFile as readFile3 } from "fs/promises";
|
|
34
11
|
import { dirname, join, parse } from "path";
|
|
35
12
|
import { fileURLToPath } from "url";
|
|
@@ -258,7 +235,7 @@ Please report this issue to https://github.com/vikejs/bati`
|
|
|
258
235
|
}
|
|
259
236
|
|
|
260
237
|
// index.ts
|
|
261
|
-
import { withIcon } from "@batijs/core";
|
|
238
|
+
import { packageManager, which, withIcon } from "@batijs/core";
|
|
262
239
|
import { cliFlags, features } from "@batijs/features";
|
|
263
240
|
import { execRules } from "@batijs/features/rules";
|
|
264
241
|
|
|
@@ -1608,13 +1585,10 @@ var createDefaultQueryTester = function(query, options) {
|
|
|
1608
1585
|
return createOperationTester(op);
|
|
1609
1586
|
};
|
|
1610
1587
|
|
|
1611
|
-
// index.ts
|
|
1612
|
-
var import_which_pm_runs = __toESM(require_which_pm_runs(), 1);
|
|
1613
|
-
|
|
1614
1588
|
// package.json
|
|
1615
1589
|
var package_default = {
|
|
1616
1590
|
name: "@batijs/cli",
|
|
1617
|
-
version: "0.0.
|
|
1591
|
+
version: "0.0.227",
|
|
1618
1592
|
type: "module",
|
|
1619
1593
|
scripts: {
|
|
1620
1594
|
"check-types": "tsc --noEmit",
|
|
@@ -1632,7 +1606,6 @@ var package_default = {
|
|
|
1632
1606
|
"@batijs/compile": "workspace:*",
|
|
1633
1607
|
"@types/node": "^18.19.14",
|
|
1634
1608
|
"@types/which": "^3.0.4",
|
|
1635
|
-
"@types/which-pm-runs": "^1.0.2",
|
|
1636
1609
|
citty: "^0.1.6",
|
|
1637
1610
|
colorette: "^2.0.20",
|
|
1638
1611
|
esbuild: "^0.23.0",
|
|
@@ -1642,8 +1615,7 @@ var package_default = {
|
|
|
1642
1615
|
tsup: "^8.1.0",
|
|
1643
1616
|
typescript: "^5.5.3",
|
|
1644
1617
|
"unplugin-purge-polyfills": "^0.0.4",
|
|
1645
|
-
vite: "^5.3.3"
|
|
1646
|
-
"which-pm-runs": "^1.1.0"
|
|
1618
|
+
vite: "^5.3.3"
|
|
1647
1619
|
},
|
|
1648
1620
|
dependencies: {
|
|
1649
1621
|
"@batijs/core": "workspace:*",
|
|
@@ -1699,7 +1671,7 @@ Choose one of them, or simply remove selected Server`
|
|
|
1699
1671
|
var __filename = fileURLToPath(import.meta.url);
|
|
1700
1672
|
var __dirname = dirname(__filename);
|
|
1701
1673
|
var isWin2 = process.platform === "win32";
|
|
1702
|
-
var pm = (
|
|
1674
|
+
var pm = packageManager();
|
|
1703
1675
|
function boilerplatesDir() {
|
|
1704
1676
|
if (existsSync2(join(__dirname, "boilerplates", "boilerplates.json"))) {
|
|
1705
1677
|
return join(__dirname, "boilerplates");
|
|
@@ -1776,13 +1748,17 @@ var defaultDef = {
|
|
|
1776
1748
|
project: {
|
|
1777
1749
|
type: "positional",
|
|
1778
1750
|
description: "Project directory",
|
|
1779
|
-
required: false
|
|
1780
|
-
default: "my-app"
|
|
1751
|
+
required: false
|
|
1781
1752
|
},
|
|
1782
1753
|
force: {
|
|
1783
1754
|
type: "boolean",
|
|
1784
1755
|
description: "If true, does no check if target directory already exists",
|
|
1785
1756
|
required: false
|
|
1757
|
+
},
|
|
1758
|
+
["skip-git"]: {
|
|
1759
|
+
type: "boolean",
|
|
1760
|
+
description: "If true, does not execute `git init`",
|
|
1761
|
+
required: false
|
|
1786
1762
|
}
|
|
1787
1763
|
};
|
|
1788
1764
|
function yn(value, default_) {
|
|
@@ -1798,10 +1774,26 @@ function yn(value, default_) {
|
|
|
1798
1774
|
}
|
|
1799
1775
|
return default_;
|
|
1800
1776
|
}
|
|
1777
|
+
function generateRandomFilename(size) {
|
|
1778
|
+
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
1779
|
+
let result = "";
|
|
1780
|
+
for (let i = 0; i < size; i++) {
|
|
1781
|
+
const randomIndex = Math.floor(Math.random() * chars.length);
|
|
1782
|
+
result += chars[randomIndex];
|
|
1783
|
+
}
|
|
1784
|
+
return result;
|
|
1785
|
+
}
|
|
1801
1786
|
async function checkArguments(args) {
|
|
1787
|
+
const projectChosenByUser = Boolean(args.project);
|
|
1788
|
+
if (!args.project) {
|
|
1789
|
+
args.project = "my-app";
|
|
1790
|
+
}
|
|
1802
1791
|
if (existsSync2(args.project)) {
|
|
1803
1792
|
const stat = await lstat(args.project);
|
|
1804
|
-
if (!
|
|
1793
|
+
if (!projectChosenByUser) {
|
|
1794
|
+
args.project = `my-app-${generateRandomFilename(5)}`;
|
|
1795
|
+
return;
|
|
1796
|
+
} else if (!stat.isDirectory()) {
|
|
1805
1797
|
console.error(
|
|
1806
1798
|
`${yellow("\u26A0")} Target ${cyan(args.project)} already exists but is not a directory. ${yellow("Aborting")}.`
|
|
1807
1799
|
);
|
|
@@ -1817,14 +1809,22 @@ async function checkArguments(args) {
|
|
|
1817
1809
|
);
|
|
1818
1810
|
process.exit(3);
|
|
1819
1811
|
}
|
|
1820
|
-
if (!args.force
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1812
|
+
if (!args.force) {
|
|
1813
|
+
const isFolderEmpty = (await readdir(args.project)).length === 0;
|
|
1814
|
+
if (!isFolderEmpty) {
|
|
1815
|
+
if (!projectChosenByUser) {
|
|
1816
|
+
args.project = `my-app-${generateRandomFilename(5)}`;
|
|
1817
|
+
return;
|
|
1818
|
+
} else {
|
|
1819
|
+
console.error(
|
|
1820
|
+
`${yellow("\u26A0")} Target folder ${cyan(
|
|
1821
|
+
args.project
|
|
1822
|
+
)} already exists and is not empty.
|
|
1825
1823
|
Continuing might erase existing files. ${yellow("Aborting")}.`
|
|
1826
|
-
|
|
1827
|
-
|
|
1824
|
+
);
|
|
1825
|
+
process.exit(4);
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
1828
|
}
|
|
1829
1829
|
}
|
|
1830
1830
|
}
|
|
@@ -1879,6 +1879,23 @@ function testFlags(flags, bl) {
|
|
|
1879
1879
|
}
|
|
1880
1880
|
return true;
|
|
1881
1881
|
}
|
|
1882
|
+
async function gitInit(cwd) {
|
|
1883
|
+
try {
|
|
1884
|
+
const exists = which("git");
|
|
1885
|
+
if (!exists) return;
|
|
1886
|
+
await new Promise((resolve, reject) => {
|
|
1887
|
+
nodeExec("git init", { cwd }, (err) => {
|
|
1888
|
+
if (err) {
|
|
1889
|
+
reject(err);
|
|
1890
|
+
} else {
|
|
1891
|
+
resolve(void 0);
|
|
1892
|
+
}
|
|
1893
|
+
});
|
|
1894
|
+
});
|
|
1895
|
+
} catch (e) {
|
|
1896
|
+
console.warn(`${yellow("\u26A0")} failed to execute \`git init\` in destination folder. Skipping.`);
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1882
1899
|
async function run() {
|
|
1883
1900
|
const dir = boilerplatesDir();
|
|
1884
1901
|
const boilerplates = await parseBoilerplates(dir);
|
|
@@ -1930,6 +1947,9 @@ async function run() {
|
|
|
1930
1947
|
},
|
|
1931
1948
|
meta
|
|
1932
1949
|
);
|
|
1950
|
+
if (!args["skip-git"]) {
|
|
1951
|
+
await gitInit(args.project);
|
|
1952
|
+
}
|
|
1933
1953
|
printOK(args.project, flags);
|
|
1934
1954
|
for (const onafter of hooksMap.get("after") ?? []) {
|
|
1935
1955
|
await onafter(meta);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@batijs/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.227",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"description": "Next-gen scaffolder. Get started with fully-functional apps, and choose any tool you want",
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@types/node": "^18.19.14",
|
|
12
12
|
"@types/which": "^3.0.4",
|
|
13
|
-
"@types/which-pm-runs": "^1.0.2",
|
|
14
13
|
"citty": "^0.1.6",
|
|
15
14
|
"colorette": "^2.0.20",
|
|
16
15
|
"esbuild": "^0.23.0",
|
|
@@ -21,13 +20,12 @@
|
|
|
21
20
|
"typescript": "^5.5.3",
|
|
22
21
|
"unplugin-purge-polyfills": "^0.0.4",
|
|
23
22
|
"vite": "^5.3.3",
|
|
24
|
-
"
|
|
25
|
-
"@batijs/
|
|
26
|
-
"@batijs/compile": "0.0.226"
|
|
23
|
+
"@batijs/build": "0.0.227",
|
|
24
|
+
"@batijs/compile": "0.0.227"
|
|
27
25
|
},
|
|
28
26
|
"dependencies": {
|
|
29
|
-
"@batijs/
|
|
30
|
-
"@batijs/
|
|
27
|
+
"@batijs/features": "0.0.227",
|
|
28
|
+
"@batijs/core": "0.0.227"
|
|
31
29
|
},
|
|
32
30
|
"bin": "./dist/index.js",
|
|
33
31
|
"exports": {
|