create-rstack 1.7.14 → 1.7.15
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 +147 -25
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -2,8 +2,9 @@ import 'module';
|
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import * as __rspack_external_child_process from "child_process";
|
|
4
4
|
import * as __rspack_external_fs from "fs";
|
|
5
|
+
import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
|
|
6
|
+
import * as __rspack_external_node_fs_promises_153e37e0 from "node:fs/promises";
|
|
5
7
|
import * as __rspack_external_path from "path";
|
|
6
|
-
import node_fs from "node:fs";
|
|
7
8
|
import node_path, { dirname } from "node:path";
|
|
8
9
|
import { fileURLToPath } from "node:url";
|
|
9
10
|
import { stripVTControlCharacters } from "node:util";
|
|
@@ -13,6 +14,115 @@ import { Writable } from "node:stream";
|
|
|
13
14
|
import node_os from "node:os";
|
|
14
15
|
import node_tty from "node:tty";
|
|
15
16
|
var __webpack_modules__ = {
|
|
17
|
+
"./node_modules/.pnpm/@vercel+detect-agent@1.0.0/node_modules/@vercel/detect-agent/dist/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
18
|
+
var __defProp = Object.defineProperty;
|
|
19
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
20
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
21
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
22
|
+
var __export = (target, all)=>{
|
|
23
|
+
for(var name in all)__defProp(target, name, {
|
|
24
|
+
get: all[name],
|
|
25
|
+
enumerable: true
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc)=>{
|
|
29
|
+
if (from && "object" == typeof from || "function" == typeof from) {
|
|
30
|
+
for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
31
|
+
get: ()=>from[key],
|
|
32
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return to;
|
|
36
|
+
};
|
|
37
|
+
var __toCommonJS = (mod)=>__copyProps(__defProp({}, "__esModule", {
|
|
38
|
+
value: true
|
|
39
|
+
}), mod);
|
|
40
|
+
var src_exports = {};
|
|
41
|
+
__export(src_exports, {
|
|
42
|
+
KNOWN_AGENTS: ()=>KNOWN_AGENTS,
|
|
43
|
+
determineAgent: ()=>determineAgent
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(src_exports);
|
|
46
|
+
var import_promises = __webpack_require__("node:fs/promises");
|
|
47
|
+
var import_node_fs = __webpack_require__("node:fs");
|
|
48
|
+
const DEVIN_LOCAL_PATH = "/opt/.devin";
|
|
49
|
+
const CURSOR = "cursor";
|
|
50
|
+
const CURSOR_CLI = "cursor-cli";
|
|
51
|
+
const CLAUDE = "claude";
|
|
52
|
+
const DEVIN = "devin";
|
|
53
|
+
const REPLIT = "replit";
|
|
54
|
+
const GEMINI = "gemini";
|
|
55
|
+
const CODEX = "codex";
|
|
56
|
+
const KNOWN_AGENTS = {
|
|
57
|
+
CURSOR,
|
|
58
|
+
CURSOR_CLI,
|
|
59
|
+
CLAUDE,
|
|
60
|
+
DEVIN,
|
|
61
|
+
REPLIT,
|
|
62
|
+
GEMINI,
|
|
63
|
+
CODEX
|
|
64
|
+
};
|
|
65
|
+
async function determineAgent() {
|
|
66
|
+
if (process.env.AI_AGENT) {
|
|
67
|
+
const name = process.env.AI_AGENT.trim();
|
|
68
|
+
if (name) return {
|
|
69
|
+
isAgent: true,
|
|
70
|
+
agent: {
|
|
71
|
+
name
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (process.env.CURSOR_TRACE_ID) return {
|
|
76
|
+
isAgent: true,
|
|
77
|
+
agent: {
|
|
78
|
+
name: CURSOR
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
if (process.env.CURSOR_AGENT) return {
|
|
82
|
+
isAgent: true,
|
|
83
|
+
agent: {
|
|
84
|
+
name: CURSOR_CLI
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
if (process.env.GEMINI_CLI) return {
|
|
88
|
+
isAgent: true,
|
|
89
|
+
agent: {
|
|
90
|
+
name: GEMINI
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
if (process.env.CODEX_SANDBOX) return {
|
|
94
|
+
isAgent: true,
|
|
95
|
+
agent: {
|
|
96
|
+
name: CODEX
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
if (process.env.CLAUDECODE || process.env.CLAUDE_CODE) return {
|
|
100
|
+
isAgent: true,
|
|
101
|
+
agent: {
|
|
102
|
+
name: CLAUDE
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
if (process.env.REPL_ID) return {
|
|
106
|
+
isAgent: true,
|
|
107
|
+
agent: {
|
|
108
|
+
name: REPLIT
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
try {
|
|
112
|
+
await (0, import_promises.access)(DEVIN_LOCAL_PATH, import_node_fs.constants.F_OK);
|
|
113
|
+
return {
|
|
114
|
+
isAgent: true,
|
|
115
|
+
agent: {
|
|
116
|
+
name: DEVIN
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
} catch (error) {}
|
|
120
|
+
return {
|
|
121
|
+
isAgent: false,
|
|
122
|
+
agent: void 0
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
},
|
|
16
126
|
"./node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
17
127
|
const cp = __webpack_require__("child_process");
|
|
18
128
|
const parse = __webpack_require__("./node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js");
|
|
@@ -794,6 +904,12 @@ var __webpack_modules__ = {
|
|
|
794
904
|
fs: function(module) {
|
|
795
905
|
module.exports = __rspack_external_fs;
|
|
796
906
|
},
|
|
907
|
+
"node:fs": function(module) {
|
|
908
|
+
module.exports = __rspack_external_node_fs_5ea92f0c;
|
|
909
|
+
},
|
|
910
|
+
"node:fs/promises": function(module) {
|
|
911
|
+
module.exports = __rspack_external_node_fs_promises_153e37e0;
|
|
912
|
+
},
|
|
797
913
|
path: function(module) {
|
|
798
914
|
module.exports = __rspack_external_path;
|
|
799
915
|
}
|
|
@@ -828,6 +944,7 @@ function __webpack_require__(moduleId) {
|
|
|
828
944
|
(()=>{
|
|
829
945
|
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
830
946
|
})();
|
|
947
|
+
var external_node_fs_ = __webpack_require__("node:fs");
|
|
831
948
|
var src = __webpack_require__("./node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js");
|
|
832
949
|
var picocolors = __webpack_require__("./node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
833
950
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
@@ -1686,6 +1803,7 @@ ${picocolors.gray(dist_d)} ${t}
|
|
|
1686
1803
|
`);
|
|
1687
1804
|
};
|
|
1688
1805
|
picocolors.gray(dist_o);
|
|
1806
|
+
var dist = __webpack_require__("./node_modules/.pnpm/@vercel+detect-agent@1.0.0/node_modules/@vercel/detect-agent/dist/index.js");
|
|
1689
1807
|
var cross_spawn = __webpack_require__("./node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js");
|
|
1690
1808
|
var cross_spawn_default = /*#__PURE__*/ __webpack_require__.n(cross_spawn);
|
|
1691
1809
|
var cjs = __webpack_require__("./node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js");
|
|
@@ -1978,7 +2096,7 @@ function pkgFromUserAgent(userAgent) {
|
|
|
1978
2096
|
};
|
|
1979
2097
|
}
|
|
1980
2098
|
function isEmptyDir(path) {
|
|
1981
|
-
const files =
|
|
2099
|
+
const files = external_node_fs_["default"].readdirSync(path);
|
|
1982
2100
|
return 0 === files.length || 1 === files.length && '.git' === files[0];
|
|
1983
2101
|
}
|
|
1984
2102
|
function parseToolsOption(tools) {
|
|
@@ -2051,7 +2169,7 @@ async function getTools({ tools, dir, template }, extraTools) {
|
|
|
2051
2169
|
function upperFirst(str) {
|
|
2052
2170
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
2053
2171
|
}
|
|
2054
|
-
const readJSON = async (path)=>JSON.parse(await
|
|
2172
|
+
const readJSON = async (path)=>JSON.parse(await external_node_fs_["default"].promises.readFile(path, 'utf-8'));
|
|
2055
2173
|
const readPackageJson = async (filePath)=>readJSON(node_path.join(filePath, 'package.json'));
|
|
2056
2174
|
const parseArgv = (processArgv)=>{
|
|
2057
2175
|
const argv = minimist_default()(processArgv.slice(2), {
|
|
@@ -2073,8 +2191,12 @@ function runCommand(command, cwd) {
|
|
|
2073
2191
|
});
|
|
2074
2192
|
}
|
|
2075
2193
|
async function create({ name, root, templates, skipFiles, getTemplateName, mapESLintTemplate, version, noteInformation, extraTools, argv: processArgv = process.argv }) {
|
|
2076
|
-
|
|
2077
|
-
|
|
2194
|
+
src_logger.greet(`\n◆ Create ${upperFirst(name)} Project`);
|
|
2195
|
+
const { isAgent } = await (0, dist.determineAgent)();
|
|
2196
|
+
if (isAgent) {
|
|
2197
|
+
console.log('');
|
|
2198
|
+
src_logger.info('To create a project non-interactively, run: npx -y create-rsbuild <DIR> --template <TEMPLATE>');
|
|
2199
|
+
}
|
|
2078
2200
|
const argv = parseArgv(processArgv);
|
|
2079
2201
|
if (argv.help) return void logHelpMessage(name, templates, extraTools);
|
|
2080
2202
|
const cwd = process.cwd();
|
|
@@ -2096,7 +2218,7 @@ async function create({ name, root, templates, skipFiles, getTemplateName, mapES
|
|
|
2096
2218
|
const { targetDir } = formatted;
|
|
2097
2219
|
const packageName = argv.packageName || formatted.packageName;
|
|
2098
2220
|
const distFolder = node_path.isAbsolute(targetDir) ? targetDir : node_path.join(cwd, targetDir);
|
|
2099
|
-
if (!argv.override &&
|
|
2221
|
+
if (!argv.override && external_node_fs_["default"].existsSync(distFolder) && !isEmptyDir(distFolder)) {
|
|
2100
2222
|
const option = checkCancel(await ve({
|
|
2101
2223
|
message: `"${targetDir}" is not empty, please choose:`,
|
|
2102
2224
|
options: [
|
|
@@ -2116,7 +2238,7 @@ async function create({ name, root, templates, skipFiles, getTemplateName, mapES
|
|
|
2116
2238
|
const tools = await getTools(argv, extraTools);
|
|
2117
2239
|
const srcFolder = node_path.join(root, `template-${templateName}`);
|
|
2118
2240
|
const commonFolder = node_path.join(root, 'template-common');
|
|
2119
|
-
if (!
|
|
2241
|
+
if (!external_node_fs_["default"].existsSync(srcFolder)) throw new Error(`Invalid input: template "${templateName}" not found.`);
|
|
2120
2242
|
copyFolder({
|
|
2121
2243
|
from: commonFolder,
|
|
2122
2244
|
to: distFolder,
|
|
@@ -2174,13 +2296,13 @@ async function create({ name, root, templates, skipFiles, getTemplateName, mapES
|
|
|
2174
2296
|
isMergePackageJson: true
|
|
2175
2297
|
});
|
|
2176
2298
|
agentsMdSearchDirs.push(toolFolder);
|
|
2177
|
-
if ('biome' === tool) await
|
|
2299
|
+
if ('biome' === tool) await external_node_fs_["default"].promises.rename(node_path.join(distFolder, 'biome.json.template'), node_path.join(distFolder, 'biome.json'));
|
|
2178
2300
|
}
|
|
2179
2301
|
const agentsFiles = collectAgentsFiles(agentsMdSearchDirs);
|
|
2180
2302
|
if (agentsFiles.length > 0) {
|
|
2181
2303
|
const mergedAgents = mergeAgentsFiles(agentsFiles);
|
|
2182
2304
|
const agentsPath = node_path.join(distFolder, 'AGENTS.md');
|
|
2183
|
-
|
|
2305
|
+
external_node_fs_["default"].writeFileSync(agentsPath, `${replacePlaceholder(mergedAgents, templateParameters)}\n`);
|
|
2184
2306
|
}
|
|
2185
2307
|
const nextSteps = noteInformation ? noteInformation : [
|
|
2186
2308
|
`1. ${picocolors_default().cyan(`cd ${targetDir}`)}`,
|
|
@@ -2198,9 +2320,9 @@ function sortObjectKeys(obj) {
|
|
|
2198
2320
|
return sortedObj;
|
|
2199
2321
|
}
|
|
2200
2322
|
function mergePackageJson(targetPackage, extraPackage) {
|
|
2201
|
-
if (!
|
|
2202
|
-
const targetJson = JSON.parse(
|
|
2203
|
-
const extraJson = JSON.parse(
|
|
2323
|
+
if (!external_node_fs_["default"].existsSync(targetPackage)) return;
|
|
2324
|
+
const targetJson = JSON.parse(external_node_fs_["default"].readFileSync(targetPackage, 'utf-8'));
|
|
2325
|
+
const extraJson = JSON.parse(external_node_fs_["default"].readFileSync(extraPackage, 'utf-8'));
|
|
2204
2326
|
const mergedJson = cjs_default()(targetJson, extraJson);
|
|
2205
2327
|
mergedJson.name = targetJson.name || extraJson.name;
|
|
2206
2328
|
for (const key of [
|
|
@@ -2208,7 +2330,7 @@ function mergePackageJson(targetPackage, extraPackage) {
|
|
|
2208
2330
|
'dependencies',
|
|
2209
2331
|
'devDependencies'
|
|
2210
2332
|
])if (key in mergedJson) mergedJson[key] = sortObjectKeys(mergedJson[key]);
|
|
2211
|
-
|
|
2333
|
+
external_node_fs_["default"].writeFileSync(targetPackage, `${JSON.stringify(mergedJson, null, 2)}\n`);
|
|
2212
2334
|
}
|
|
2213
2335
|
const isMarkdown = (file)=>file.endsWith('.md') || file.endsWith('.mdx');
|
|
2214
2336
|
const replacePlaceholder = (content, templateParameters)=>{
|
|
@@ -2225,14 +2347,14 @@ function copyFolder({ from, to, version, packageName, templateParameters, isMerg
|
|
|
2225
2347
|
'dist',
|
|
2226
2348
|
...skipFiles
|
|
2227
2349
|
];
|
|
2228
|
-
|
|
2350
|
+
external_node_fs_["default"].mkdirSync(to, {
|
|
2229
2351
|
recursive: true
|
|
2230
2352
|
});
|
|
2231
|
-
for (const file of
|
|
2353
|
+
for (const file of external_node_fs_["default"].readdirSync(from)){
|
|
2232
2354
|
if (allSkipFiles.includes(file)) continue;
|
|
2233
2355
|
const srcFile = node_path.resolve(from, file);
|
|
2234
2356
|
const distFile = renameFiles[file] ? node_path.resolve(to, renameFiles[file]) : node_path.resolve(to, file);
|
|
2235
|
-
const stat =
|
|
2357
|
+
const stat = external_node_fs_["default"].statSync(srcFile);
|
|
2236
2358
|
if (stat.isDirectory()) copyFolder({
|
|
2237
2359
|
from: srcFile,
|
|
2238
2360
|
to: distFile,
|
|
@@ -2242,14 +2364,14 @@ function copyFolder({ from, to, version, packageName, templateParameters, isMerg
|
|
|
2242
2364
|
});
|
|
2243
2365
|
else if ('package.json' === file) {
|
|
2244
2366
|
const targetPackage = node_path.resolve(to, 'package.json');
|
|
2245
|
-
if (isMergePackageJson &&
|
|
2246
|
-
else
|
|
2367
|
+
if (isMergePackageJson && external_node_fs_["default"].existsSync(targetPackage)) mergePackageJson(targetPackage, srcFile);
|
|
2368
|
+
else external_node_fs_["default"].copyFileSync(srcFile, distFile);
|
|
2247
2369
|
updatePackageJson(distFile, version, packageName);
|
|
2248
2370
|
} else {
|
|
2249
|
-
|
|
2371
|
+
external_node_fs_["default"].copyFileSync(srcFile, distFile);
|
|
2250
2372
|
if (templateParameters && isMarkdown(distFile)) {
|
|
2251
|
-
const content =
|
|
2252
|
-
|
|
2373
|
+
const content = external_node_fs_["default"].readFileSync(distFile, 'utf-8');
|
|
2374
|
+
external_node_fs_["default"].writeFileSync(distFile, replacePlaceholder(content, templateParameters));
|
|
2253
2375
|
}
|
|
2254
2376
|
}
|
|
2255
2377
|
}
|
|
@@ -2262,7 +2384,7 @@ const isStableVersion = (version)=>[
|
|
|
2262
2384
|
'nightly'
|
|
2263
2385
|
].every((tag)=>!version.includes(tag));
|
|
2264
2386
|
const updatePackageJson = (pkgJsonPath, version, name)=>{
|
|
2265
|
-
let content =
|
|
2387
|
+
let content = external_node_fs_["default"].readFileSync(pkgJsonPath, 'utf-8');
|
|
2266
2388
|
if ('string' == typeof version) {
|
|
2267
2389
|
const targetVersion = isStableVersion(version) ? `^${version}` : version;
|
|
2268
2390
|
content = content.replace(/workspace:\*/g, targetVersion);
|
|
@@ -2276,11 +2398,11 @@ const updatePackageJson = (pkgJsonPath, version, name)=>{
|
|
|
2276
2398
|
const projectName = node_path.basename(node_path.dirname(pkgJsonPath));
|
|
2277
2399
|
if (projectName.length) pkg.name = projectName;
|
|
2278
2400
|
} else if (name) pkg.name = name;
|
|
2279
|
-
|
|
2401
|
+
external_node_fs_["default"].writeFileSync(pkgJsonPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
2280
2402
|
};
|
|
2281
2403
|
function readAgentsFile(filePath) {
|
|
2282
|
-
if (!
|
|
2283
|
-
return
|
|
2404
|
+
if (!external_node_fs_["default"].existsSync(filePath)) return null;
|
|
2405
|
+
return external_node_fs_["default"].readFileSync(filePath, 'utf-8');
|
|
2284
2406
|
}
|
|
2285
2407
|
function parseAgentsContent(content) {
|
|
2286
2408
|
const sections = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-rstack",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.15",
|
|
4
4
|
"description": "Create a new Rstack project",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"@types/fs-extra": "^11.0.4",
|
|
50
50
|
"@types/minimist": "^1.2.5",
|
|
51
51
|
"@types/node": "24.10.1",
|
|
52
|
+
"@vercel/detect-agent": "^1.0.0",
|
|
52
53
|
"cross-spawn": "^7.0.6",
|
|
53
54
|
"deepmerge": "^4.3.1",
|
|
54
55
|
"fs-extra": "^11.3.2",
|