create-nyoworks 2.3.0 → 2.3.1
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/init.js +55 -54
- package/package.json +1 -1
package/dist/init.js
CHANGED
|
@@ -2,6 +2,7 @@ import prompts from "prompts";
|
|
|
2
2
|
import pc from "picocolors";
|
|
3
3
|
import fs from "fs-extra";
|
|
4
4
|
import path from "path";
|
|
5
|
+
import os from "os";
|
|
5
6
|
import { execa } from "execa";
|
|
6
7
|
import { replacePlaceholders } from "./replace.js";
|
|
7
8
|
const REPO = "naimozcan/nyoworks-framework";
|
|
@@ -39,22 +40,14 @@ function generateDatabaseName(name) {
|
|
|
39
40
|
.replace(/[^a-z0-9]+/g, "_")
|
|
40
41
|
.replace(/^_|_$/g, "") + "_dev";
|
|
41
42
|
}
|
|
42
|
-
async function
|
|
43
|
-
const url = `https://
|
|
44
|
-
const tempDir = path.join(
|
|
43
|
+
async function downloadRepo(repo, branch) {
|
|
44
|
+
const url = `https://github.com/${repo}/archive/refs/heads/${branch}.tar.gz`;
|
|
45
|
+
const tempDir = path.join(os.tmpdir(), `nyoworks-${Date.now()}`);
|
|
46
|
+
const tarFile = path.join(tempDir, "repo.tar.gz");
|
|
45
47
|
await fs.ensureDir(tempDir);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const extractedDir = path.join(tempDir, `nyoworks-framework-${branch}`);
|
|
50
|
-
const sourcePath = subPath ? path.join(extractedDir, subPath) : extractedDir;
|
|
51
|
-
if (await fs.pathExists(sourcePath)) {
|
|
52
|
-
await fs.copy(sourcePath, targetDir, { overwrite: true });
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
finally {
|
|
56
|
-
await fs.remove(tempDir);
|
|
57
|
-
}
|
|
48
|
+
await execa("curl", ["-L", "-o", tarFile, url]);
|
|
49
|
+
await execa("tar", ["-xzf", tarFile, "-C", tempDir]);
|
|
50
|
+
return path.join(tempDir, `nyoworks-framework-${branch}`);
|
|
58
51
|
}
|
|
59
52
|
export async function createProject(projectName) {
|
|
60
53
|
console.log();
|
|
@@ -102,22 +95,47 @@ export async function createProject(projectName) {
|
|
|
102
95
|
console.log(pc.red(`Directory ${slug} already exists.`));
|
|
103
96
|
process.exit(1);
|
|
104
97
|
}
|
|
105
|
-
await fs.ensureDir(targetDir);
|
|
106
98
|
console.log();
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
99
|
+
process.stdout.write(pc.cyan("Downloading from GitHub..."));
|
|
100
|
+
let repoDir;
|
|
101
|
+
try {
|
|
102
|
+
repoDir = await downloadRepo(REPO, BRANCH);
|
|
103
|
+
console.log(pc.green(" done"));
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
console.log(pc.red(" failed"));
|
|
107
|
+
console.error(pc.red("Failed to download from GitHub. Check your internet connection."));
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
process.stdout.write(pc.dim(" Copying files..."));
|
|
111
|
+
await fs.ensureDir(targetDir);
|
|
112
|
+
const corePaths = [
|
|
113
|
+
"packages/api",
|
|
114
|
+
"packages/api-client",
|
|
115
|
+
"packages/database",
|
|
116
|
+
"packages/validators",
|
|
117
|
+
"packages/shared",
|
|
118
|
+
"packages/ui",
|
|
119
|
+
"packages/assets",
|
|
120
|
+
"apps/server",
|
|
121
|
+
"docs",
|
|
122
|
+
"mcp-server",
|
|
123
|
+
".claude",
|
|
120
124
|
];
|
|
125
|
+
for (const p of corePaths) {
|
|
126
|
+
const src = path.join(repoDir, p);
|
|
127
|
+
const dest = path.join(targetDir, p);
|
|
128
|
+
if (await fs.pathExists(src)) {
|
|
129
|
+
await fs.copy(src, dest);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
for (const platform of platforms) {
|
|
133
|
+
const src = path.join(repoDir, `apps/${platform}`);
|
|
134
|
+
const dest = path.join(targetDir, `apps/${platform}`);
|
|
135
|
+
if (await fs.pathExists(src)) {
|
|
136
|
+
await fs.copy(src, dest);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
121
139
|
const rootFiles = [
|
|
122
140
|
"package.json",
|
|
123
141
|
"pnpm-workspace.yaml",
|
|
@@ -127,32 +145,15 @@ export async function createProject(projectName) {
|
|
|
127
145
|
".gitignore",
|
|
128
146
|
"nyoworks.config.yaml",
|
|
129
147
|
];
|
|
130
|
-
for (const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
for (const platform of platforms) {
|
|
136
|
-
process.stdout.write(pc.dim(` Downloading apps/${platform}...`));
|
|
137
|
-
await downloadFromGitHub(REPO, `apps/${platform}`, path.join(targetDir, `apps/${platform}`), BRANCH);
|
|
138
|
-
console.log(pc.green(" ✓"));
|
|
139
|
-
}
|
|
140
|
-
process.stdout.write(pc.dim(" Downloading root files..."));
|
|
141
|
-
await downloadFromGitHub(REPO, "", targetDir, BRANCH);
|
|
142
|
-
const allPlatforms = ["web", "mobile", "desktop"];
|
|
143
|
-
for (const platform of allPlatforms) {
|
|
144
|
-
if (!platforms.includes(platform)) {
|
|
145
|
-
const platformDir = path.join(targetDir, "apps", platform);
|
|
146
|
-
if (await fs.pathExists(platformDir)) {
|
|
147
|
-
await fs.remove(platformDir);
|
|
148
|
-
}
|
|
148
|
+
for (const file of rootFiles) {
|
|
149
|
+
const src = path.join(repoDir, file);
|
|
150
|
+
const dest = path.join(targetDir, file);
|
|
151
|
+
if (await fs.pathExists(src)) {
|
|
152
|
+
await fs.copy(src, dest);
|
|
149
153
|
}
|
|
150
154
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
await fs.remove(createNyoworksDir);
|
|
154
|
-
}
|
|
155
|
-
console.log(pc.green(" ✓"));
|
|
155
|
+
await fs.remove(path.dirname(repoDir));
|
|
156
|
+
console.log(pc.green(" done"));
|
|
156
157
|
const placeholders = {
|
|
157
158
|
"${PROJECT_NAME}": name,
|
|
158
159
|
"${PROJECT_CODE}": code,
|
|
@@ -161,7 +162,7 @@ export async function createProject(projectName) {
|
|
|
161
162
|
};
|
|
162
163
|
process.stdout.write(pc.dim(" Replacing placeholders..."));
|
|
163
164
|
await replacePlaceholders(targetDir, placeholders);
|
|
164
|
-
console.log(pc.green("
|
|
165
|
+
console.log(pc.green(" done"));
|
|
165
166
|
for (const feature of features) {
|
|
166
167
|
const featureDoc = path.join(targetDir, "docs", "bible", "features", `${feature}.md`);
|
|
167
168
|
const content = `# Feature: ${feature.charAt(0).toUpperCase() + feature.slice(1)}
|