notra-editor 1.0.0-beta.3 → 1.0.0
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.
Potentially problematic release.
This version of notra-editor might be problematic. Click here for more details.
- package/dist/index.d.ts +2 -1
- package/dist/index.js +46 -57
- package/package.json +42 -53
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
export { }
|
package/dist/index.js
CHANGED
|
@@ -34,24 +34,35 @@ async function fetchRegistry(url) {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
// src/utils/validator.ts
|
|
38
|
+
import { existsSync } from "fs";
|
|
39
|
+
import { join } from "path";
|
|
40
|
+
function validateProject(cwd = process.cwd()) {
|
|
41
|
+
const packageJsonPath = join(cwd, "package.json");
|
|
42
|
+
if (existsSync(packageJsonPath)) {
|
|
43
|
+
return { valid: true };
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
valid: false,
|
|
47
|
+
error: "package.json not found. Please run this command in a project root directory."
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
37
51
|
// src/utils/conflict.ts
|
|
38
|
-
import { existsSync, readdirSync } from "fs";
|
|
39
|
-
import { join, isAbsolute } from "path";
|
|
52
|
+
import { existsSync as existsSync2, readdirSync } from "fs";
|
|
53
|
+
import { join as join2, isAbsolute } from "path";
|
|
40
54
|
function detectConflicts(targetDir, cwd = process.cwd()) {
|
|
41
|
-
const absolutePath = isAbsolute(targetDir) ? targetDir :
|
|
42
|
-
if (!
|
|
55
|
+
const absolutePath = isAbsolute(targetDir) ? targetDir : join2(cwd, targetDir);
|
|
56
|
+
if (!existsSync2(absolutePath)) {
|
|
43
57
|
return {
|
|
44
58
|
hasConflict: false,
|
|
45
59
|
existingFiles: []
|
|
46
60
|
};
|
|
47
61
|
}
|
|
48
|
-
const files = readdirSync(absolutePath, {
|
|
49
|
-
recursive: true,
|
|
50
|
-
withFileTypes: true
|
|
51
|
-
}).filter((dirent) => dirent.isFile()).map((dirent) => {
|
|
62
|
+
const files = readdirSync(absolutePath, { recursive: true, withFileTypes: true }).filter((dirent) => dirent.isFile()).map((dirent) => {
|
|
52
63
|
const parentPath = dirent.parentPath || dirent.path;
|
|
53
64
|
const relativePath = parentPath.replace(absolutePath, "").replace(/^[/\\]/, "");
|
|
54
|
-
return relativePath ?
|
|
65
|
+
return relativePath ? join2(relativePath, dirent.name) : dirent.name;
|
|
55
66
|
});
|
|
56
67
|
return {
|
|
57
68
|
hasConflict: files.length > 0,
|
|
@@ -61,13 +72,13 @@ function detectConflicts(targetDir, cwd = process.cwd()) {
|
|
|
61
72
|
|
|
62
73
|
// src/utils/copier.ts
|
|
63
74
|
import { writeFileSync, mkdirSync } from "fs";
|
|
64
|
-
import { join as
|
|
75
|
+
import { join as join3, dirname, isAbsolute as isAbsolute2 } from "path";
|
|
65
76
|
async function copyFiles(files, targetDir, cwd = process.cwd()) {
|
|
66
77
|
const copiedFiles = [];
|
|
67
|
-
const absoluteTargetDir = isAbsolute2(targetDir) ? targetDir :
|
|
78
|
+
const absoluteTargetDir = isAbsolute2(targetDir) ? targetDir : join3(cwd, targetDir);
|
|
68
79
|
try {
|
|
69
80
|
for (const file of files) {
|
|
70
|
-
const targetPath =
|
|
81
|
+
const targetPath = join3(absoluteTargetDir, file.path);
|
|
71
82
|
const targetDirPath = dirname(targetPath);
|
|
72
83
|
mkdirSync(targetDirPath, { recursive: true });
|
|
73
84
|
writeFileSync(targetPath, file.content, "utf-8");
|
|
@@ -117,30 +128,9 @@ async function installDependencies(dependencies, cwd = process.cwd()) {
|
|
|
117
128
|
}
|
|
118
129
|
}
|
|
119
130
|
|
|
120
|
-
// src/utils/prompts.ts
|
|
121
|
-
import prompts from "prompts";
|
|
122
|
-
function isInteractive() {
|
|
123
|
-
return process.stdin.isTTY === true;
|
|
124
|
-
}
|
|
125
|
-
async function confirmOverwrite(targetDir) {
|
|
126
|
-
if (!isInteractive()) {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
const response = await prompts({
|
|
130
|
-
type: "confirm",
|
|
131
|
-
name: "overwrite",
|
|
132
|
-
message: `Directory "${targetDir}" already exists. Do you want to overwrite it?`,
|
|
133
|
-
initial: false
|
|
134
|
-
});
|
|
135
|
-
if (response.overwrite === void 0) {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
return response.overwrite;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
131
|
// src/utils/ui.ts
|
|
142
|
-
import kleur from "kleur";
|
|
143
132
|
import ora from "ora";
|
|
133
|
+
import kleur from "kleur";
|
|
144
134
|
function createSpinner() {
|
|
145
135
|
const spinner = ora();
|
|
146
136
|
return {
|
|
@@ -168,18 +158,25 @@ function info(message) {
|
|
|
168
158
|
console.log(kleur.cyan(message));
|
|
169
159
|
}
|
|
170
160
|
|
|
171
|
-
// src/utils/
|
|
172
|
-
import
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
161
|
+
// src/utils/prompts.ts
|
|
162
|
+
import prompts from "prompts";
|
|
163
|
+
function isInteractive() {
|
|
164
|
+
return process.stdin.isTTY === true;
|
|
165
|
+
}
|
|
166
|
+
async function confirmOverwrite(targetDir) {
|
|
167
|
+
if (!isInteractive()) {
|
|
168
|
+
return false;
|
|
178
169
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
170
|
+
const response = await prompts({
|
|
171
|
+
type: "confirm",
|
|
172
|
+
name: "overwrite",
|
|
173
|
+
message: `Directory "${targetDir}" already exists. Do you want to overwrite it?`,
|
|
174
|
+
initial: false
|
|
175
|
+
});
|
|
176
|
+
if (response.overwrite === void 0) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
return response.overwrite;
|
|
183
180
|
}
|
|
184
181
|
|
|
185
182
|
// src/commands/init.ts
|
|
@@ -198,9 +195,7 @@ async function initCommand(options = {}) {
|
|
|
198
195
|
if (options.force) {
|
|
199
196
|
info(`Overwriting existing files in ${CONSTANTS.TARGET_DIR}...`);
|
|
200
197
|
} else if (!isInteractive()) {
|
|
201
|
-
error(
|
|
202
|
-
`Directory "${CONSTANTS.TARGET_DIR}" already exists. Use --force to overwrite.`
|
|
203
|
-
);
|
|
198
|
+
error(`Directory "${CONSTANTS.TARGET_DIR}" already exists. Use --force to overwrite.`);
|
|
204
199
|
process.exit(1);
|
|
205
200
|
} else {
|
|
206
201
|
const shouldOverwrite = await confirmOverwrite(CONSTANTS.TARGET_DIR);
|
|
@@ -215,9 +210,7 @@ async function initCommand(options = {}) {
|
|
|
215
210
|
const fetchResult = await fetchRegistry(registryUrl);
|
|
216
211
|
if (!fetchResult.success || !fetchResult.data) {
|
|
217
212
|
spinner.fail("Failed to fetch registry");
|
|
218
|
-
error(
|
|
219
|
-
fetchResult.error || "Network request failed. Please check your internet connection."
|
|
220
|
-
);
|
|
213
|
+
error(fetchResult.error || "Network request failed. Please check your internet connection.");
|
|
221
214
|
process.exit(1);
|
|
222
215
|
}
|
|
223
216
|
spinner.succeed("Registry fetched successfully");
|
|
@@ -226,14 +219,10 @@ async function initCommand(options = {}) {
|
|
|
226
219
|
const copyResult = await copyFiles(registry.files, CONSTANTS.TARGET_DIR);
|
|
227
220
|
if (!copyResult.success) {
|
|
228
221
|
spinner.fail("Failed to copy files");
|
|
229
|
-
error(
|
|
230
|
-
copyResult.error || "File write failed. Please check directory permissions."
|
|
231
|
-
);
|
|
222
|
+
error(copyResult.error || "File write failed. Please check directory permissions.");
|
|
232
223
|
process.exit(1);
|
|
233
224
|
}
|
|
234
|
-
spinner.succeed(
|
|
235
|
-
`Copied ${copyResult.copiedFiles.length} files to ${CONSTANTS.TARGET_DIR}`
|
|
236
|
-
);
|
|
225
|
+
spinner.succeed(`Copied ${copyResult.copiedFiles.length} files to ${CONSTANTS.TARGET_DIR}`);
|
|
237
226
|
if (registry.dependencies.length > 0) {
|
|
238
227
|
spinner.start("Installing dependencies...");
|
|
239
228
|
const installResult = await installDependencies(registry.dependencies);
|
package/package.json
CHANGED
|
@@ -1,53 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "notra-editor",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
},
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
"scripts": {
|
|
45
|
-
"build": "tsup",
|
|
46
|
-
"dev": "tsup --watch",
|
|
47
|
-
"test": "vitest run",
|
|
48
|
-
"test:watch": "vitest",
|
|
49
|
-
"release": "changeset version",
|
|
50
|
-
"pub:beta": "pnpm build && pnpm publish --no-git-checks --access public --tag beta",
|
|
51
|
-
"pub:release": "pnpm build && pnpm publish --access public"
|
|
52
|
-
}
|
|
53
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "notra-editor",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI tool to scaffold notra-editor into your project",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"notra-editor": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsup",
|
|
14
|
+
"dev": "tsup --watch",
|
|
15
|
+
"test": "vitest run",
|
|
16
|
+
"test:watch": "vitest"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"commander": "^14.0.0",
|
|
20
|
+
"kleur": "^4.1.5",
|
|
21
|
+
"ora": "^8.2.0",
|
|
22
|
+
"prompts": "^2.4.2"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^20",
|
|
26
|
+
"@types/prompts": "^2.4.9",
|
|
27
|
+
"fast-check": "^3.19.0",
|
|
28
|
+
"tsup": "^8.5.0",
|
|
29
|
+
"typescript": "^5",
|
|
30
|
+
"vitest": "^4.0.18"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"tiptap",
|
|
37
|
+
"editor",
|
|
38
|
+
"cli",
|
|
39
|
+
"scaffold"
|
|
40
|
+
],
|
|
41
|
+
"license": "MIT"
|
|
42
|
+
}
|