create-rsbuild 0.0.0 → 0.0.7
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/LICENSE +21 -0
- package/README.md +19 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +98 -0
- package/package.json +40 -6
- package/template-common/README.md +29 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present Bytedance, Inc. and its affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://rsbuild.dev" target="blank"><img src="https://github.com/web-infra-dev/rsbuild/assets/7237365/84abc13e-b620-468f-a90b-dbf28e7e9427" alt="Rsbuild Logo" /></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# Rsbuild
|
|
6
|
+
|
|
7
|
+
Unleash the power of Rspack with the out-of-the-box build tool.
|
|
8
|
+
|
|
9
|
+
## Documentation
|
|
10
|
+
|
|
11
|
+
https://rsbuild.dev/
|
|
12
|
+
|
|
13
|
+
## Contributing
|
|
14
|
+
|
|
15
|
+
Please read the [Contributing Guide](https://github.com/web-infra-dev/rsbuild/blob/main/CONTRIBUTING.md).
|
|
16
|
+
|
|
17
|
+
## License
|
|
18
|
+
|
|
19
|
+
Rsbuild is [MIT licensed](https://github.com/web-infra-dev/rsbuild/blob/main/LICENSE).
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
var import_fs = __toESM(require("fs"));
|
|
26
|
+
var import_path = __toESM(require("path"));
|
|
27
|
+
var import_rslog = require("rslog");
|
|
28
|
+
var import_prompts = require("@clack/prompts");
|
|
29
|
+
function checkCancel(value) {
|
|
30
|
+
if ((0, import_prompts.isCancel)(value)) {
|
|
31
|
+
(0, import_prompts.cancel)("Operation cancelled.");
|
|
32
|
+
process.exit(0);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function formatTargetDir(targetDir) {
|
|
36
|
+
return targetDir.trim().replace(/\/+$/g, "");
|
|
37
|
+
}
|
|
38
|
+
async function main() {
|
|
39
|
+
console.log("");
|
|
40
|
+
import_rslog.logger.greet("◆ Create Rsbuild Project");
|
|
41
|
+
const cwd = process.cwd();
|
|
42
|
+
let targetDir = await (0, import_prompts.text)({
|
|
43
|
+
message: "Input target folder",
|
|
44
|
+
placeholder: "my-project",
|
|
45
|
+
validate(value) {
|
|
46
|
+
if (value.length === 0) {
|
|
47
|
+
return `Target folder is required`;
|
|
48
|
+
}
|
|
49
|
+
if (import_fs.default.existsSync(import_path.default.join(cwd, value))) {
|
|
50
|
+
return `"${value}" is not empty, please input another folder`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
checkCancel(targetDir);
|
|
55
|
+
targetDir = formatTargetDir(targetDir);
|
|
56
|
+
const framework = await (0, import_prompts.select)({
|
|
57
|
+
message: "Select framework",
|
|
58
|
+
options: [
|
|
59
|
+
{ value: "react", label: "React" },
|
|
60
|
+
{ value: "vue3", label: "Vue 3" },
|
|
61
|
+
{ value: "vue2", label: "Vue 2" }
|
|
62
|
+
]
|
|
63
|
+
});
|
|
64
|
+
checkCancel(framework);
|
|
65
|
+
const language = await (0, import_prompts.select)({
|
|
66
|
+
message: "Select language",
|
|
67
|
+
options: [
|
|
68
|
+
{ value: "ts", label: "TypeScript" },
|
|
69
|
+
{ value: "js", label: "JavaScript" }
|
|
70
|
+
]
|
|
71
|
+
});
|
|
72
|
+
checkCancel(language);
|
|
73
|
+
const srcFolder = import_path.default.join(cwd, `template-${framework}-${language}`);
|
|
74
|
+
const commonFolder = import_path.default.join(cwd, `template-common`);
|
|
75
|
+
const distFolder = import_path.default.join(cwd, targetDir);
|
|
76
|
+
copyFolder(commonFolder, distFolder);
|
|
77
|
+
copyFolder(srcFolder, distFolder);
|
|
78
|
+
const nextSteps = [`cd ${targetDir}`, "npm i", "npm dev"];
|
|
79
|
+
(0, import_prompts.note)(nextSteps.join("\n"), "Next steps");
|
|
80
|
+
(0, import_prompts.outro)("Done.");
|
|
81
|
+
}
|
|
82
|
+
function copyFolder(src, dist) {
|
|
83
|
+
const renameFiles = {
|
|
84
|
+
gitignore: ".gitignore"
|
|
85
|
+
};
|
|
86
|
+
import_fs.default.mkdirSync(dist, { recursive: true });
|
|
87
|
+
for (const file of import_fs.default.readdirSync(src)) {
|
|
88
|
+
const srcFile = import_path.default.resolve(src, file);
|
|
89
|
+
const distFile = renameFiles[file] ? import_path.default.resolve(dist, renameFiles[file]) : import_path.default.resolve(dist, file);
|
|
90
|
+
const stat = import_fs.default.statSync(srcFile);
|
|
91
|
+
if (stat.isDirectory()) {
|
|
92
|
+
copyFolder(srcFile, distFile);
|
|
93
|
+
} else {
|
|
94
|
+
import_fs.default.copyFileSync(srcFile, distFile);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,11 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-rsbuild",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"description": "Create a new Rsbuild project",
|
|
4
|
+
"homepage": "https://rsbuild.dev",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/web-infra-dev/rsbuild",
|
|
8
|
+
"directory": "packages/create-rsbuild"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"version": "0.0.7",
|
|
12
|
+
"types": "./src/index.ts",
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"bin": {
|
|
15
|
+
"create-rsbuild": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"template-*"
|
|
26
|
+
],
|
|
6
27
|
"scripts": {
|
|
7
|
-
"
|
|
28
|
+
"dev": "modern build --watch",
|
|
29
|
+
"build": "modern build"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@clack/prompts": "^0.7.0",
|
|
33
|
+
"rslog": "^1.1.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^16",
|
|
37
|
+
"typescript": "^5"
|
|
8
38
|
},
|
|
9
|
-
"
|
|
10
|
-
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"registry": "https://registry.npmjs.org/",
|
|
41
|
+
"access": "public",
|
|
42
|
+
"provenance": true,
|
|
43
|
+
"types": "./dist/index.d.ts"
|
|
44
|
+
}
|
|
11
45
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Rsbuild Project
|
|
2
|
+
|
|
3
|
+
## Setup
|
|
4
|
+
|
|
5
|
+
Install the dependencies:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm install
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Get Started
|
|
12
|
+
|
|
13
|
+
Start the dev server:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
pnpm dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Build the app for production:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
pnpm build
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Preview the production build locally:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
pnpm serve
|
|
29
|
+
```
|