notra-editor 1.0.0 → 1.1.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 CHANGED
@@ -1,2 +1 @@
1
-
2
- export { }
1
+ #!/usr/bin/env node
package/dist/index.js CHANGED
@@ -34,35 +34,24 @@ 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
-
51
37
  // src/utils/conflict.ts
52
- import { existsSync as existsSync2, readdirSync } from "fs";
53
- import { join as join2, isAbsolute } from "path";
38
+ import { existsSync, readdirSync } from "fs";
39
+ import { join, isAbsolute } from "path";
54
40
  function detectConflicts(targetDir, cwd = process.cwd()) {
55
- const absolutePath = isAbsolute(targetDir) ? targetDir : join2(cwd, targetDir);
56
- if (!existsSync2(absolutePath)) {
41
+ const absolutePath = isAbsolute(targetDir) ? targetDir : join(cwd, targetDir);
42
+ if (!existsSync(absolutePath)) {
57
43
  return {
58
44
  hasConflict: false,
59
45
  existingFiles: []
60
46
  };
61
47
  }
62
- const files = readdirSync(absolutePath, { recursive: true, withFileTypes: true }).filter((dirent) => dirent.isFile()).map((dirent) => {
48
+ const files = readdirSync(absolutePath, {
49
+ recursive: true,
50
+ withFileTypes: true
51
+ }).filter((dirent) => dirent.isFile()).map((dirent) => {
63
52
  const parentPath = dirent.parentPath || dirent.path;
64
53
  const relativePath = parentPath.replace(absolutePath, "").replace(/^[/\\]/, "");
65
- return relativePath ? join2(relativePath, dirent.name) : dirent.name;
54
+ return relativePath ? join(relativePath, dirent.name) : dirent.name;
66
55
  });
67
56
  return {
68
57
  hasConflict: files.length > 0,
@@ -72,13 +61,13 @@ function detectConflicts(targetDir, cwd = process.cwd()) {
72
61
 
73
62
  // src/utils/copier.ts
74
63
  import { writeFileSync, mkdirSync } from "fs";
75
- import { join as join3, dirname, isAbsolute as isAbsolute2 } from "path";
64
+ import { join as join2, dirname, isAbsolute as isAbsolute2 } from "path";
76
65
  async function copyFiles(files, targetDir, cwd = process.cwd()) {
77
66
  const copiedFiles = [];
78
- const absoluteTargetDir = isAbsolute2(targetDir) ? targetDir : join3(cwd, targetDir);
67
+ const absoluteTargetDir = isAbsolute2(targetDir) ? targetDir : join2(cwd, targetDir);
79
68
  try {
80
69
  for (const file of files) {
81
- const targetPath = join3(absoluteTargetDir, file.path);
70
+ const targetPath = join2(absoluteTargetDir, file.path);
82
71
  const targetDirPath = dirname(targetPath);
83
72
  mkdirSync(targetDirPath, { recursive: true });
84
73
  writeFileSync(targetPath, file.content, "utf-8");
@@ -128,9 +117,30 @@ async function installDependencies(dependencies, cwd = process.cwd()) {
128
117
  }
129
118
  }
130
119
 
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
+
131
141
  // src/utils/ui.ts
132
- import ora from "ora";
133
142
  import kleur from "kleur";
143
+ import ora from "ora";
134
144
  function createSpinner() {
135
145
  const spinner = ora();
136
146
  return {
@@ -158,25 +168,18 @@ function info(message) {
158
168
  console.log(kleur.cyan(message));
159
169
  }
160
170
 
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;
169
- }
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;
171
+ // src/utils/validator.ts
172
+ import { existsSync as existsSync2 } from "fs";
173
+ import { join as join3 } from "path";
174
+ function validateProject(cwd = process.cwd()) {
175
+ const packageJsonPath = join3(cwd, "package.json");
176
+ if (existsSync2(packageJsonPath)) {
177
+ return { valid: true };
178
178
  }
179
- return response.overwrite;
179
+ return {
180
+ valid: false,
181
+ error: "package.json not found. Please run this command in a project root directory."
182
+ };
180
183
  }
181
184
 
182
185
  // src/commands/init.ts
@@ -195,7 +198,9 @@ async function initCommand(options = {}) {
195
198
  if (options.force) {
196
199
  info(`Overwriting existing files in ${CONSTANTS.TARGET_DIR}...`);
197
200
  } else if (!isInteractive()) {
198
- error(`Directory "${CONSTANTS.TARGET_DIR}" already exists. Use --force to overwrite.`);
201
+ error(
202
+ `Directory "${CONSTANTS.TARGET_DIR}" already exists. Use --force to overwrite.`
203
+ );
199
204
  process.exit(1);
200
205
  } else {
201
206
  const shouldOverwrite = await confirmOverwrite(CONSTANTS.TARGET_DIR);
@@ -210,7 +215,9 @@ async function initCommand(options = {}) {
210
215
  const fetchResult = await fetchRegistry(registryUrl);
211
216
  if (!fetchResult.success || !fetchResult.data) {
212
217
  spinner.fail("Failed to fetch registry");
213
- error(fetchResult.error || "Network request failed. Please check your internet connection.");
218
+ error(
219
+ fetchResult.error || "Network request failed. Please check your internet connection."
220
+ );
214
221
  process.exit(1);
215
222
  }
216
223
  spinner.succeed("Registry fetched successfully");
@@ -219,10 +226,14 @@ async function initCommand(options = {}) {
219
226
  const copyResult = await copyFiles(registry.files, CONSTANTS.TARGET_DIR);
220
227
  if (!copyResult.success) {
221
228
  spinner.fail("Failed to copy files");
222
- error(copyResult.error || "File write failed. Please check directory permissions.");
229
+ error(
230
+ copyResult.error || "File write failed. Please check directory permissions."
231
+ );
223
232
  process.exit(1);
224
233
  }
225
- spinner.succeed(`Copied ${copyResult.copiedFiles.length} files to ${CONSTANTS.TARGET_DIR}`);
234
+ spinner.succeed(
235
+ `Copied ${copyResult.copiedFiles.length} files to ${CONSTANTS.TARGET_DIR}`
236
+ );
226
237
  if (registry.dependencies.length > 0) {
227
238
  spinner.start("Installing dependencies...");
228
239
  const installResult = await installDependencies(registry.dependencies);
@@ -237,8 +248,9 @@ async function initCommand(options = {}) {
237
248
  success("\n\u2728 notra-editor initialized successfully!");
238
249
  info(`
239
250
  Editor files have been copied to: ${CONSTANTS.TARGET_DIR}`);
240
- info("You can now import the editor in your project:");
241
- info(` import { Editor } from '@/components/notra-editor/editor';`);
251
+ info("\nYou can now import the components:");
252
+ info(` import { Editor } from '@/components/notra-editor/core/editor';`);
253
+ info(` import { Viewer } from '@/components/notra-editor/core/viewer';`);
242
254
  }
243
255
 
244
256
  // src/index.ts
package/package.json CHANGED
@@ -1,42 +1,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
- }
1
+ {
2
+ "name": "notra-editor",
3
+ "type": "module",
4
+ "version": "1.1.0",
5
+ "description": "CLI tool to scaffold notra-editor into your project",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/Levix0501/notra-editor.git",
10
+ "directory": "packages/cli"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "keywords": [
16
+ "tiptap",
17
+ "editor",
18
+ "cli",
19
+ "scaffold"
20
+ ],
21
+ "bin": {
22
+ "notra-editor": "./dist/index.js"
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "engines": {
28
+ "node": ">=18"
29
+ },
30
+ "dependencies": {
31
+ "commander": "^14.0.0",
32
+ "kleur": "^4.1.5",
33
+ "ora": "^8.2.0",
34
+ "prompts": "^2.4.2"
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "^20",
38
+ "@types/prompts": "^2.4.9",
39
+ "fast-check": "^3.19.0",
40
+ "tsup": "^8.5.0",
41
+ "typescript": "^5",
42
+ "vitest": "^4.0.18"
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
+ }