@automerge/create-vite-app 2.6.0-subduction.11 → 2.6.0-subduction.12
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 +77 -0
- package/package.json +1 -1
package/dist/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import child_process from "child_process";
|
|
5
|
+
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);
|
|
12
|
+
}
|
|
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);
|
|
28
|
+
}
|
|
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
|
|
34
|
+
logs
|
|
35
|
+
*.log
|
|
36
|
+
npm-debug.log*
|
|
37
|
+
yarn-debug.log*
|
|
38
|
+
yarn-error.log*
|
|
39
|
+
pnpm-debug.log*
|
|
40
|
+
lerna-debug.log*
|
|
41
|
+
|
|
42
|
+
node_modules
|
|
43
|
+
dist
|
|
44
|
+
dist-ssr
|
|
45
|
+
*.local
|
|
46
|
+
|
|
47
|
+
# Editor directories and files
|
|
48
|
+
.vscode/*
|
|
49
|
+
!.vscode/extensions.json
|
|
50
|
+
.idea
|
|
51
|
+
.DS_Store
|
|
52
|
+
*.suo
|
|
53
|
+
*.ntvs*
|
|
54
|
+
*.njsproj
|
|
55
|
+
*.sln
|
|
56
|
+
*.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);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
fs.copyFileSync(src, dest);
|
|
68
|
+
}
|
|
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);
|
|
76
|
+
}
|
|
77
|
+
}
|
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.12",
|
|
4
4
|
"description": "Create an automerge-repo app which uses Vite",
|
|
5
5
|
"repository": "https://github.com/automerge/automerge-repo/tree/master/packages/create-vite-app",
|
|
6
6
|
"author": "Alex Good <alex@memoryandthought.me>",
|