create-rsbuild 0.0.21 → 0.0.23

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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # create-rsbuild
2
2
 
3
+ ## 0.0.23
4
+
5
+ ## 0.0.22
6
+
7
+ ### Patch Changes
8
+
9
+ - 73cac183: feat(create-rsbuild): add new lit template
10
+ - 6c00e30: fix(create-rsbuild): missing tsconfig.json in vanilla template
11
+ - 6c00e30: feat(create-rsbuild): improve next steps message
12
+ - 82e7c249: fix(create-rsbuild): incorrect title in sample code
13
+
3
14
  ## 0.0.21
4
15
 
5
16
  ### Patch Changes
package/dist/index.js CHANGED
@@ -35,10 +35,22 @@ function checkCancel(value) {
35
35
  function formatTargetDir(targetDir) {
36
36
  return targetDir.trim().replace(/\/+$/g, "");
37
37
  }
38
+ function pkgFromUserAgent(userAgent) {
39
+ if (!userAgent)
40
+ return void 0;
41
+ const pkgSpec = userAgent.split(" ")[0];
42
+ const pkgSpecArr = pkgSpec.split("/");
43
+ return {
44
+ name: pkgSpecArr[0],
45
+ version: pkgSpecArr[1]
46
+ };
47
+ }
38
48
  async function main() {
39
49
  console.log("");
40
50
  import_rslog.logger.greet("◆ Create Rsbuild Project");
41
51
  const cwd = process.cwd();
52
+ const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent);
53
+ const pkgManager = pkgInfo ? pkgInfo.name : "npm";
42
54
  const packageRoot = import_path.default.resolve(__dirname, "..");
43
55
  const packageJsonPath = import_path.default.join(packageRoot, "package.json");
44
56
  const { version } = require(packageJsonPath);
@@ -62,6 +74,7 @@ async function main() {
62
74
  { value: "react", label: "React" },
63
75
  { value: "vue3", label: "Vue 3" },
64
76
  { value: "vue2", label: "Vue 2" },
77
+ { value: "lit", label: "Lit" },
65
78
  { value: "svelte", label: "Svelte" },
66
79
  { value: "vanilla", label: "Vanilla" }
67
80
  ]
@@ -80,7 +93,7 @@ async function main() {
80
93
  const distFolder = import_path.default.join(cwd, targetDir);
81
94
  copyFolder(commonFolder, distFolder, version);
82
95
  copyFolder(srcFolder, distFolder, version);
83
- const nextSteps = [`cd ${targetDir}`, "npm i", "npm run dev"];
96
+ const nextSteps = [`cd ${targetDir}`, `${pkgManager} i`, `${pkgManager} run dev`];
84
97
  (0, import_prompts.note)(nextSteps.join("\n"), "Next steps");
85
98
  (0, import_prompts.outro)("Done.");
86
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-rsbuild",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "Create a new Rsbuild project",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@clack/prompts": "^0.7.0",
25
- "rslog": "^1.1.0"
25
+ "rslog": "^1.1.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^16",
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "rsbuild-lit-js",
3
+ "private": true,
4
+ "version": "1.0.0",
5
+ "scripts": {
6
+ "dev": "rsbuild dev --open",
7
+ "build": "rsbuild build",
8
+ "preview": "rsbuild preview"
9
+ },
10
+ "devDependencies": {
11
+ "@rsbuild/core": "workspace:*",
12
+ "lit": "^3.0.2"
13
+ }
14
+ }
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from '@rsbuild/core';
2
+
3
+ export default defineConfig({
4
+ html: {
5
+ template: './src/index.html',
6
+ },
7
+ });
@@ -0,0 +1,6 @@
1
+ body {
2
+ margin: 0;
3
+ color: #fff;
4
+ font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
5
+ background-image: linear-gradient(to bottom, #020917, #101725);
6
+ }
@@ -0,0 +1,5 @@
1
+ <!doctype html>
2
+ <head></head>
3
+ <body>
4
+ <my-element />
5
+ </body>
@@ -0,0 +1,4 @@
1
+ import './index.css';
2
+ import { MyElement } from './my-element';
3
+
4
+ customElements.define('my-element', MyElement);
@@ -0,0 +1,34 @@
1
+ import { html, css, LitElement } from 'lit';
2
+
3
+ export class MyElement extends LitElement {
4
+ static styles = css`
5
+ .content {
6
+ display: flex;
7
+ min-height: 100vh;
8
+ line-height: 1.1;
9
+ text-align: center;
10
+ flex-direction: column;
11
+ justify-content: center;
12
+ }
13
+
14
+ .content h1 {
15
+ font-size: 3.6rem;
16
+ font-weight: 700;
17
+ }
18
+
19
+ .content p {
20
+ font-size: 1.2rem;
21
+ font-weight: 400;
22
+ opacity: 0.5;
23
+ }
24
+ `;
25
+
26
+ render() {
27
+ return html`
28
+ <div class="content">
29
+ <h1>Rsbuild with Lit</h1>
30
+ <p>Start building amazing things with Rsbuild.</p>
31
+ </div>
32
+ `;
33
+ }
34
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "rsbuild-lit-ts",
3
+ "private": true,
4
+ "version": "1.0.0",
5
+ "scripts": {
6
+ "dev": "rsbuild dev --open",
7
+ "build": "rsbuild build",
8
+ "preview": "rsbuild preview"
9
+ },
10
+ "devDependencies": {
11
+ "@rsbuild/core": "workspace:*",
12
+ "lit": "^3.0.2",
13
+ "typescript": "^5.2.2"
14
+ }
15
+ }
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from '@rsbuild/core';
2
+
3
+ export default defineConfig({
4
+ html: {
5
+ template: './src/index.html',
6
+ },
7
+ });
@@ -0,0 +1 @@
1
+ /// <reference types="@rsbuild/core/types" />
@@ -0,0 +1,6 @@
1
+ body {
2
+ margin: 0;
3
+ color: #fff;
4
+ font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
5
+ background-image: linear-gradient(to bottom, #020917, #101725);
6
+ }
@@ -0,0 +1,5 @@
1
+ <!doctype html>
2
+ <head></head>
3
+ <body>
4
+ <my-element />
5
+ </body>
@@ -0,0 +1,4 @@
1
+ import './index.css';
2
+ import { MyElement } from './my-element';
3
+
4
+ customElements.define('my-element', MyElement);
@@ -0,0 +1,34 @@
1
+ import { html, css, LitElement } from 'lit';
2
+
3
+ export class MyElement extends LitElement {
4
+ static styles = css`
5
+ .content {
6
+ display: flex;
7
+ min-height: 100vh;
8
+ line-height: 1.1;
9
+ text-align: center;
10
+ flex-direction: column;
11
+ justify-content: center;
12
+ }
13
+
14
+ .content h1 {
15
+ font-size: 3.6rem;
16
+ font-weight: 700;
17
+ }
18
+
19
+ .content p {
20
+ font-size: 1.2rem;
21
+ font-weight: 400;
22
+ opacity: 0.5;
23
+ }
24
+ `;
25
+
26
+ render() {
27
+ return html`
28
+ <div class="content">
29
+ <h1>Rsbuild with Lit</h1>
30
+ <p>Start building amazing things with Rsbuild.</p>
31
+ </div>
32
+ `;
33
+ }
34
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "lib": ["DOM", "ES2020"],
5
+ "module": "ESNext",
6
+ "strict": true,
7
+ "skipLibCheck": true,
8
+ "isolatedModules": true,
9
+ "resolveJsonModule": true,
10
+ "moduleResolution": "bundler"
11
+ },
12
+ "include": ["src"]
13
+ }
@@ -2,7 +2,7 @@ import './index.css';
2
2
 
3
3
  document.querySelector('#root').innerHTML = `
4
4
  <div class="content">
5
- <h1>Rsbuild with React</h1>
5
+ <h1>Vanilla Rsbuild</h1>
6
6
  <p>Start building amazing things with Rsbuild.</p>
7
7
  </div>
8
8
  `;
@@ -2,7 +2,7 @@ import './index.css';
2
2
 
3
3
  document.querySelector('#root')!.innerHTML = `
4
4
  <div class="content">
5
- <h1>Rsbuild with React</h1>
5
+ <h1>Vanilla Rsbuild</h1>
6
6
  <p>Start building amazing things with Rsbuild.</p>
7
7
  </div>
8
8
  `;
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "lib": ["DOM", "ES2020"],
5
+ "module": "ESNext",
6
+ "strict": true,
7
+ "skipLibCheck": true,
8
+ "isolatedModules": true,
9
+ "resolveJsonModule": true,
10
+ "moduleResolution": "bundler"
11
+ },
12
+ "include": ["src"]
13
+ }