@automerge/create-vite-app 2.6.0-subduction.3 → 2.6.0-subduction.30

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 CHANGED
@@ -1,36 +1,29 @@
1
1
  #!/usr/bin/env node
2
- import fs from "fs";
3
- import path from "path";
4
- import child_process from "child_process";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
5
4
  import { fileURLToPath } from "node:url";
6
- const execSync = child_process.execSync;
7
- function main() {
8
- const projectName = process.argv[2];
9
- if (!projectName) {
10
- console.error("Please provide a project name");
11
- process.exit(1);
5
+ import { intro, outro, text, isCancel, cancel, log } from "@clack/prompts";
6
+ const detectPackageManager = () => {
7
+ const ua = process.env.npm_config_user_agent ?? "";
8
+ return ua.split(" ")[0]?.split("/")[0] || "npm";
9
+ };
10
+ const copy = (src, dest) => {
11
+ if (fs.statSync(src).isDirectory()) {
12
+ copyDir(src, dest);
12
13
  }
13
- const templateDir = path.resolve(fileURLToPath(import.meta.url), "../../template");
14
- const root = path.join(process.cwd(), projectName);
15
- const write = (file, content) => {
16
- const targetPath = path.join(root, file);
17
- if (content) {
18
- fs.writeFileSync(targetPath, content);
19
- }
20
- else {
21
- copy(path.join(templateDir, file), targetPath);
22
- }
23
- };
24
- fs.mkdirSync(projectName);
25
- const files = fs.readdirSync(templateDir);
26
- for (const file of files.filter(f => f !== "package.json")) {
27
- write(file);
14
+ else {
15
+ fs.copyFileSync(src, dest);
28
16
  }
29
- const pkg = JSON.parse(fs.readFileSync(path.join(templateDir, `package.json`), "utf-8"));
30
- pkg.name = projectName;
31
- write("package.json", JSON.stringify(pkg, null, 2));
32
- write(".gitignore", `
33
- # Logs
17
+ };
18
+ const copyDir = (srcDir, destDir) => {
19
+ fs.mkdirSync(destDir, { recursive: true });
20
+ for (const file of fs.readdirSync(srcDir)) {
21
+ copy(path.resolve(srcDir, file), path.resolve(destDir, file));
22
+ }
23
+ };
24
+ // Written here rather than shipped as a template file: npm strips files named
25
+ // .gitignore from published packages, so the template can't carry one directly.
26
+ const GITIGNORE = `# Logs
34
27
  logs
35
28
  *.log
36
29
  npm-debug.log*
@@ -54,24 +47,53 @@ dist-ssr
54
47
  *.njsproj
55
48
  *.sln
56
49
  *.sw?
57
- `);
58
- execSync(`cd ${projectName} && npm install`, { stdio: "inherit" });
59
- }
60
- main();
61
- function copy(src, dest) {
62
- const stat = fs.statSync(src);
63
- if (stat.isDirectory()) {
64
- copyDir(src, dest);
50
+ `;
51
+ const main = async () => {
52
+ intro("create-vite-app · Automerge + Vite + React");
53
+ let projectName = process.argv[2];
54
+ if (!projectName) {
55
+ const answer = await text({
56
+ message: "Project name?",
57
+ placeholder: "my-automerge-app",
58
+ validate: value => value && value.trim().length > 0
59
+ ? undefined
60
+ : "Please enter a project name",
61
+ });
62
+ if (isCancel(answer)) {
63
+ cancel("Scaffolding cancelled.");
64
+ process.exit(0);
65
+ }
66
+ projectName = answer.trim();
65
67
  }
66
- else {
67
- fs.copyFileSync(src, dest);
68
+ const root = path.join(process.cwd(), projectName);
69
+ if (fs.existsSync(root)) {
70
+ cancel(`Directory "${projectName}" already exists.`);
71
+ process.exit(1);
68
72
  }
69
- }
70
- function copyDir(srcDir, destDir) {
71
- fs.mkdirSync(destDir, { recursive: true });
72
- for (const file of fs.readdirSync(srcDir)) {
73
- const srcFile = path.resolve(srcDir, file);
74
- const destFile = path.resolve(destDir, file);
75
- copy(srcFile, destFile);
73
+ const templateDir = path.resolve(fileURLToPath(import.meta.url), "../../template");
74
+ fs.mkdirSync(root, { recursive: true });
75
+ for (const file of fs.readdirSync(templateDir)) {
76
+ if (file === "package.json")
77
+ continue;
78
+ copy(path.join(templateDir, file), path.join(root, file));
76
79
  }
77
- }
80
+ // Copy package.json with the chosen project name.
81
+ const pkg = JSON.parse(fs.readFileSync(path.join(templateDir, "package.json"), "utf-8"));
82
+ pkg.name = projectName;
83
+ fs.writeFileSync(path.join(root, "package.json"), JSON.stringify(pkg, null, 2) + "\n");
84
+ fs.writeFileSync(path.join(root, ".gitignore"), GITIGNORE);
85
+ log.success(`Created ${projectName}`);
86
+ const pm = detectPackageManager();
87
+ const run = pm === "npm" ? "npm run" : pm;
88
+ outro([
89
+ "Next steps:",
90
+ ` cd ${projectName}`,
91
+ ` ${pm} install`,
92
+ ` ${run} dev`,
93
+ ].join("\n"));
94
+ };
95
+ main().catch(error => {
96
+ console.error(error);
97
+ process.exit(1);
98
+ });
99
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "@automerge/create-vite-app",
3
- "version": "2.6.0-subduction.3",
3
+ "version": "2.6.0-subduction.30",
4
4
  "description": "Create an automerge-repo app which uses Vite",
5
- "repository": "https://github.com/automerge/automerge-repo/tree/master/packages/create-vite-app",
5
+ "repository": "https://github.com/automerge/automerge-repo/tree/main/packages/create-vite-app",
6
6
  "author": "Alex Good <alex@memoryandthought.me>",
7
7
  "license": "MIT",
8
8
  "type": "module",
9
- "bin": "dist/index.js",
10
9
  "files": [
11
10
  "dist/index.js",
12
11
  "template"
@@ -16,12 +15,34 @@
16
15
  "access": "public",
17
16
  "tag": "subduction"
18
17
  },
18
+ "dependencies": {
19
+ "@clack/prompts": "^1.4.0"
20
+ },
19
21
  "devDependencies": {
20
- "execa": "^8.0.1"
22
+ "@types/node": "^22.19.19",
23
+ "execa": "^9.6.1",
24
+ "typescript": "^6.0.3"
25
+ },
26
+ "engines": {
27
+ "node": ">=22.13"
28
+ },
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "default": "./dist/index.js"
33
+ },
34
+ "./*": {
35
+ "types": "./dist/*.d.ts",
36
+ "default": "./dist/*.js"
37
+ },
38
+ "./package.json": "./package.json"
21
39
  },
22
40
  "scripts": {
23
41
  "build": "tsc",
24
42
  "postbuild": "node postbuild.js",
25
43
  "test": "node test.js"
44
+ },
45
+ "bin": {
46
+ "create-vite-app": "dist/index.js"
26
47
  }
27
48
  }
@@ -29,18 +29,22 @@ jobs:
29
29
  runs-on: ubuntu-latest
30
30
  steps:
31
31
  - name: Checkout
32
- uses: actions/checkout@v4
32
+ uses: actions/checkout@v5
33
+ - name: Install pnpm
34
+ uses: pnpm/action-setup@v4
35
+ with:
36
+ version: 11
33
37
  - name: Set up Node
34
- uses: actions/setup-node@v4
38
+ uses: actions/setup-node@v5
35
39
  with:
36
- node-version: 20
37
- cache: "npm"
40
+ node-version: 22
41
+ cache: pnpm
38
42
  - name: Install dependencies
39
- run: yarn
43
+ run: pnpm install
40
44
  - name: Build
41
- run: yarn build
45
+ run: pnpm build
42
46
  - name: Setup Pages
43
- uses: actions/configure-pages@v4
47
+ uses: actions/configure-pages@v5
44
48
  - name: Upload artifact
45
49
  uses: actions/upload-pages-artifact@v3
46
50
  with:
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "./node_modules/oxlint/configuration_schema.json",
3
+ "plugins": ["react", "typescript", "import"],
4
+ "categories": {
5
+ "correctness": "error"
6
+ },
7
+ "ignorePatterns": ["dist"],
8
+ "settings": {
9
+ "react": { "version": "19" }
10
+ }
11
+ }
@@ -1,3 +1,37 @@
1
- # Vite + React + Automerge
1
+ # Automerge + Vite + React
2
2
 
3
- This template provides a minimal vite app with React and Automerge
3
+ A starter app built with [Automerge](https://automerge.org),
4
+ [Vite](https://vite.dev), and React. State is a local-first Automerge document
5
+ that syncs peer-to-peer over a WebSocket sync server and across browser tabs.
6
+
7
+ ## Develop
8
+
9
+ ```sh
10
+ pnpm install
11
+ pnpm dev
12
+ ```
13
+
14
+ Open the app in two tabs (or share the URL, including its `#…` document hash)
15
+ and watch the counter synchronize in real time.
16
+
17
+ ## Build
18
+
19
+ ```sh
20
+ pnpm build
21
+ ```
22
+
23
+ The static site is emitted to `dist/`.
24
+
25
+ ## Lint
26
+
27
+ ```sh
28
+ pnpm lint
29
+ ```
30
+
31
+ Linting uses [oxlint](https://oxc.rs).
32
+
33
+ ## Deploy
34
+
35
+ A GitHub Pages workflow is included at `.github/workflows/deploy.yml`. If you
36
+ deploy to a project page (`https://<user>.github.io/<repo>/`), set `base` in
37
+ `vite.config.ts` to `"/<repo>/"`.
@@ -1,8 +1,7 @@
1
- <!DOCTYPE html>
1
+ <!doctype html>
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
6
  <title>Meet Automerge</title>
8
7
  </head>
@@ -1,30 +1,29 @@
1
1
  {
2
2
  "name": "projectName",
3
3
  "private": true,
4
- "version": "1.2.1",
4
+ "version": "0.0.0",
5
5
  "type": "module",
6
+ "engines": {
7
+ "node": ">=22.18"
8
+ },
6
9
  "scripts": {
7
10
  "dev": "vite",
8
11
  "build": "tsc && vite build",
9
- "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
10
- "preview": "vite preview"
12
+ "preview": "vite preview",
13
+ "lint": "oxlint"
11
14
  },
12
15
  "dependencies": {
13
- "@automerge/react": "^2.0.0-beta.5",
14
- "react": "^18.3.0",
15
- "react-dom": "^18.3.0"
16
+ "@automerge/react": "^2.5.6",
17
+ "react": "^19.2.0",
18
+ "react-dom": "^19.2.0"
16
19
  },
17
20
  "devDependencies": {
18
- "@types/react": "^18.2.64",
19
- "@types/react-dom": "^18.2.21",
20
- "@typescript-eslint/eslint-plugin": "^7.3.1",
21
- "@typescript-eslint/parser": "^7.3.1",
22
- "@vitejs/plugin-react": "^4.2.1",
23
- "eslint": "^8.57.0",
24
- "eslint-plugin-react-hooks": "^4.6.0",
25
- "eslint-plugin-react-refresh": "^0.4.5",
26
- "typescript": "^5.2.2",
27
- "vite": "^5.1.6",
28
- "vite-plugin-wasm": "^3"
21
+ "@types/react": "^19.0.0",
22
+ "@types/react-dom": "^19.0.0",
23
+ "@vitejs/plugin-react": "^6.0.2",
24
+ "oxlint": "^1.67.0",
25
+ "typescript": "^6.0.3",
26
+ "vite": "^8.0.14",
27
+ "vite-plugin-wasm": "^3.6.0"
29
28
  }
30
29
  }
@@ -24,7 +24,7 @@ const repo = new Repo({
24
24
  const rootDocUrl = `${document.location.hash.substring(1)}`
25
25
  let handle
26
26
  if (isValidAutomergeUrl(rootDocUrl)) {
27
- handle = repo.find(rootDocUrl)
27
+ handle = await repo.find(rootDocUrl)
28
28
  } else {
29
29
  handle = repo.create<{ counter?: Counter }>()
30
30
  handle.change(d => (d.counter = new Counter()))
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "ES2020",
3
+ "target": "ESNext",
4
4
  "useDefineForClassFields": true,
5
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
5
+ "lib": ["ESNext", "DOM", "DOM.Iterable"],
6
6
  "module": "ESNext",
7
7
  "skipLibCheck": true,
8
8
 
@@ -20,6 +20,5 @@
20
20
  "noUnusedParameters": true,
21
21
  "noFallthroughCasesInSwitch": true
22
22
  },
23
- "include": ["src"],
24
- "references": [{ "path": "./tsconfig.node.json" }]
23
+ "include": ["src"]
25
24
  }
@@ -1,18 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- env: { browser: true, es2020: true },
4
- extends: [
5
- "eslint:recommended",
6
- "plugin:@typescript-eslint/recommended",
7
- "plugin:react-hooks/recommended",
8
- ],
9
- ignorePatterns: ["dist", ".eslintrc.cjs"],
10
- parser: "@typescript-eslint/parser",
11
- plugins: ["react-refresh"],
12
- rules: {
13
- "react-refresh/only-export-components": [
14
- "warn",
15
- { allowConstantExport: true },
16
- ],
17
- },
18
- }
@@ -1,11 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "composite": true,
4
- "skipLibCheck": true,
5
- "module": "ESNext",
6
- "moduleResolution": "bundler",
7
- "allowSyntheticDefaultImports": true,
8
- "strict": true
9
- },
10
- "include": ["vite.config.ts"]
11
- }