@automerge/create-vite-app 2.6.0-subduction.29 → 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 +68 -47
- package/package.json +21 -2
- package/template/.github/workflows/deploy.yml +11 -7
- package/template/.oxlintrc.json +11 -0
- package/template/README.md +36 -2
- package/template/index.html +0 -1
- package/template/package.json +16 -17
- package/template/src/main.tsx +1 -1
- package/template/tsconfig.json +3 -4
- package/template/.eslintrc.cjs +0 -18
- package/template/tsconfig.node.json +0 -11
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
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
14
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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,25 +47,53 @@ dist-ssr
|
|
|
54
47
|
*.njsproj
|
|
55
48
|
*.sln
|
|
56
49
|
*.sw?
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
67
|
-
|
|
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
|
-
|
|
71
|
-
fs.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
+
});
|
|
78
99
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automerge/create-vite-app",
|
|
3
|
-
"version": "2.6.0-subduction.
|
|
3
|
+
"version": "2.6.0-subduction.30",
|
|
4
4
|
"description": "Create an automerge-repo app which uses Vite",
|
|
5
5
|
"repository": "https://github.com/automerge/automerge-repo/tree/main/packages/create-vite-app",
|
|
6
6
|
"author": "Alex Good <alex@memoryandthought.me>",
|
|
@@ -15,8 +15,27 @@
|
|
|
15
15
|
"access": "public",
|
|
16
16
|
"tag": "subduction"
|
|
17
17
|
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@clack/prompts": "^1.4.0"
|
|
20
|
+
},
|
|
18
21
|
"devDependencies": {
|
|
19
|
-
"
|
|
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"
|
|
20
39
|
},
|
|
21
40
|
"scripts": {
|
|
22
41
|
"build": "tsc",
|
|
@@ -29,18 +29,22 @@ jobs:
|
|
|
29
29
|
runs-on: ubuntu-latest
|
|
30
30
|
steps:
|
|
31
31
|
- name: Checkout
|
|
32
|
-
uses: actions/checkout@
|
|
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@
|
|
38
|
+
uses: actions/setup-node@v5
|
|
35
39
|
with:
|
|
36
|
-
node-version:
|
|
37
|
-
cache:
|
|
40
|
+
node-version: 22
|
|
41
|
+
cache: pnpm
|
|
38
42
|
- name: Install dependencies
|
|
39
|
-
run:
|
|
43
|
+
run: pnpm install
|
|
40
44
|
- name: Build
|
|
41
|
-
run:
|
|
45
|
+
run: pnpm build
|
|
42
46
|
- name: Setup Pages
|
|
43
|
-
uses: actions/configure-pages@
|
|
47
|
+
uses: actions/configure-pages@v5
|
|
44
48
|
- name: Upload artifact
|
|
45
49
|
uses: actions/upload-pages-artifact@v3
|
|
46
50
|
with:
|
package/template/README.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Automerge + Vite + React
|
|
2
2
|
|
|
3
|
-
|
|
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>/"`.
|
package/template/index.html
CHANGED
package/template/package.json
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "projectName",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "
|
|
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
|
-
"
|
|
10
|
-
"
|
|
12
|
+
"preview": "vite preview",
|
|
13
|
+
"lint": "oxlint"
|
|
11
14
|
},
|
|
12
15
|
"dependencies": {
|
|
13
|
-
"@automerge/react": "^2.
|
|
14
|
-
"react": "^
|
|
15
|
-
"react-dom": "^
|
|
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": "^
|
|
19
|
-
"@types/react-dom": "^
|
|
20
|
-
"@
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
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
|
}
|
package/template/src/main.tsx
CHANGED
|
@@ -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()))
|
package/template/tsconfig.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
3
|
+
"target": "ESNext",
|
|
4
4
|
"useDefineForClassFields": true,
|
|
5
|
-
"lib": ["
|
|
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
|
}
|
package/template/.eslintrc.cjs
DELETED
|
@@ -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
|
-
}
|