create-manifest 1.3.4 → 2.0.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.
Files changed (57) hide show
  1. package/README.md +40 -21
  2. package/index.js +51 -0
  3. package/package.json +11 -89
  4. package/starter/.claude/settings.local.json +23 -0
  5. package/starter/.env.example +1 -0
  6. package/starter/README.md +26 -0
  7. package/starter/components.json +24 -0
  8. package/starter/package.json +42 -0
  9. package/starter/src/flows/list-pokemons.flow.ts +129 -0
  10. package/starter/src/server.ts +169 -0
  11. package/starter/src/web/PokemonList.tsx +126 -0
  12. package/starter/src/web/components/blog-post-card.tsx +288 -0
  13. package/starter/src/web/components/blog-post-list.tsx +291 -0
  14. package/starter/src/web/components/payment-methods.tsx +201 -0
  15. package/starter/src/web/components/table.tsx +478 -0
  16. package/starter/src/web/components/ui/.gitkeep +0 -0
  17. package/starter/src/web/components/ui/button.tsx +62 -0
  18. package/starter/src/web/components/ui/checkbox.tsx +30 -0
  19. package/starter/src/web/globals.css +98 -0
  20. package/starter/src/web/hooks/.gitkeep +0 -0
  21. package/starter/src/web/lib/utils.ts +6 -0
  22. package/starter/src/web/root.tsx +36 -0
  23. package/starter/src/web/tsconfig.json +3 -0
  24. package/starter/tsconfig.json +25 -0
  25. package/starter/tsconfig.web.json +24 -0
  26. package/starter/vite.config.ts +37 -0
  27. package/assets/monorepo/README.md +0 -52
  28. package/assets/monorepo/api-package.json +0 -9
  29. package/assets/monorepo/api-readme.md +0 -50
  30. package/assets/monorepo/manifest.yml +0 -34
  31. package/assets/monorepo/root-package.json +0 -15
  32. package/assets/monorepo/web-package.json +0 -10
  33. package/assets/monorepo/web-readme.md +0 -9
  34. package/assets/standalone/README.md +0 -50
  35. package/assets/standalone/api-package.json +0 -9
  36. package/assets/standalone/manifest.yml +0 -34
  37. package/bin/dev.cmd +0 -3
  38. package/bin/dev.js +0 -5
  39. package/bin/run.cmd +0 -3
  40. package/bin/run.js +0 -5
  41. package/dist/commands/index.d.ts +0 -65
  42. package/dist/commands/index.js +0 -480
  43. package/dist/index.d.ts +0 -1
  44. package/dist/index.js +0 -1
  45. package/dist/utils/GetBackendFileContent.d.ts +0 -1
  46. package/dist/utils/GetBackendFileContent.js +0 -21
  47. package/dist/utils/GetLatestPackageVersion.d.ts +0 -1
  48. package/dist/utils/GetLatestPackageVersion.js +0 -5
  49. package/dist/utils/UpdateExtensionJsonFile.d.ts +0 -6
  50. package/dist/utils/UpdateExtensionJsonFile.js +0 -8
  51. package/dist/utils/UpdatePackageJsonFile.d.ts +0 -18
  52. package/dist/utils/UpdatePackageJsonFile.js +0 -21
  53. package/dist/utils/UpdateSettingsJsonFile.d.ts +0 -4
  54. package/dist/utils/UpdateSettingsJsonFile.js +0 -6
  55. package/dist/utils/helpers.d.ts +0 -1
  56. package/dist/utils/helpers.js +0 -11
  57. package/oclif.manifest.json +0 -47
@@ -1,65 +0,0 @@
1
- import { Command } from '@oclif/core';
2
- export default class CreateManifest extends Command {
3
- static description: string;
4
- static args: {
5
- firstArg: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
6
- };
7
- static flags: {
8
- backendFile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
- cursor: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
- copilot: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
- windsurf: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
- };
13
- /**
14
- * The run method is called when the command is run.
15
- *
16
- * Steps:
17
- * 1. Create a folder named after the first arg or ask for it
18
- * 2. Create a folder with the name `manifest`.
19
- * 3. Create a file inside the folder with the name `manifest.yml`.
20
- * 4. Update the `package.json` file with the new packages and scripts.
21
- * 5. Update the .vscode/extensions.json file with the recommended extensions.
22
- * 6. Update the .vscode/settings.json file with the recommended settings.
23
- * 7. Update the .gitignore file with the recommended settings.
24
- * 8. Update the .env file with the environment variables.
25
- * 9. If no README.md file exists, create one.
26
- * 10. Add optional files based on flags
27
- * 11. Install the new packages.
28
- * 12. Serve the new app.
29
- * 13. Wait for the server to start.
30
- * 14. Seed the database.
31
- * 15. Open the browser.
32
- */
33
- run(): Promise<void>;
34
- /**
35
- * Check if the server is ready.
36
- *
37
- * @returns {Promise<boolean>} - Returns a promise that resolves to a boolean.
38
- *
39
- **/
40
- isServerReady(): Promise<boolean>;
41
- /**
42
- * Wait for the server to be ready.
43
- *
44
- * @returns a promise that resolves to void when the server is ready.
45
- *
46
- **/
47
- waitForServerToBeReady(): Promise<void>;
48
- /**
49
- * Transform a JSON with comments to a JSON without comments.
50
- *
51
- * @param jsonString - The JSON with comments.
52
- *
53
- * @returns the JSON without comments.
54
- *
55
- **/
56
- removeComments(jsonString: string): string;
57
- /**
58
- * Kill a process without logging an error if it fails.
59
- *
60
- * @param {number} pid - The process ID.
61
- * @returns {Promise<void>} - A promise that resolves when the process is killed.
62
- *
63
- */
64
- silentKill(pid: number): Promise<void>;
65
- }
@@ -1,480 +0,0 @@
1
- import { Args, Command, Flags } from '@oclif/core';
2
- import axios from 'axios';
3
- import { exec as execCp, spawn } from 'node:child_process';
4
- import * as fs from 'node:fs';
5
- import * as crypto from 'node:crypto';
6
- import * as path from 'node:path';
7
- import { fileURLToPath } from 'node:url';
8
- import { promisify } from 'node:util';
9
- import ora from 'ora';
10
- import treeKill from 'tree-kill';
11
- import { parse } from 'jsonc-parser';
12
- import { updateExtensionJsonFile } from '../utils/UpdateExtensionJsonFile.js';
13
- import { updatePackageJsonFile } from '../utils/UpdatePackageJsonFile.js';
14
- import { updateSettingsJsonFile } from '../utils/UpdateSettingsJsonFile.js';
15
- import { getLatestPackageVersion } from '../utils/GetLatestPackageVersion.js';
16
- import { getBackendFileContent } from '../utils/GetBackendFileContent.js';
17
- import { input } from '@inquirer/prompts';
18
- import { slugify } from '../utils/helpers.js';
19
- import chalk from 'chalk';
20
- const exec = promisify(execCp);
21
- /**
22
- * Execute a command in a specific directory with cross-platform support
23
- * @param command - The command to execute
24
- * @param cwd - The working directory
25
- * @returns Promise with stdout and stderr
26
- */
27
- async function execInDirectory(command, cwd) {
28
- return exec(command, { cwd });
29
- }
30
- /**
31
- * Spawn a command in a specific directory that runs in the background
32
- * @param command - The command to execute
33
- * @param args - The command arguments
34
- * @param cwd - The working directory
35
- * @returns ChildProcess
36
- */
37
- function spawnInDirectory(command, args, cwd) {
38
- const isWindows = process.platform === 'win32';
39
- if (isWindows) {
40
- // On Windows, use shell to resolve npm command
41
- return spawn(command, args, {
42
- cwd,
43
- stdio: 'pipe',
44
- detached: false,
45
- shell: true
46
- });
47
- }
48
- else {
49
- // On Unix systems, spawn directly
50
- return spawn(command, args, {
51
- cwd,
52
- stdio: 'pipe',
53
- detached: false
54
- });
55
- }
56
- }
57
- export default class CreateManifest extends Command {
58
- static description = 'Create a new Manifest project with the default files and folders.';
59
- static args = {
60
- firstArg: Args.string({
61
- name: 'name',
62
- description: 'The name for the new workspace and the initial project. It will be used for the root directory.'
63
- })
64
- };
65
- static flags = {
66
- backendFile: Flags.string({
67
- summary: 'The remote file to use as a template for the manifest.yml file. If not provided, the default file will be used.'
68
- }),
69
- cursor: Flags.boolean(),
70
- copilot: Flags.boolean(),
71
- windsurf: Flags.boolean()
72
- };
73
- /**
74
- * The run method is called when the command is run.
75
- *
76
- * Steps:
77
- * 1. Create a folder named after the first arg or ask for it
78
- * 2. Create a folder with the name `manifest`.
79
- * 3. Create a file inside the folder with the name `manifest.yml`.
80
- * 4. Update the `package.json` file with the new packages and scripts.
81
- * 5. Update the .vscode/extensions.json file with the recommended extensions.
82
- * 6. Update the .vscode/settings.json file with the recommended settings.
83
- * 7. Update the .gitignore file with the recommended settings.
84
- * 8. Update the .env file with the environment variables.
85
- * 9. If no README.md file exists, create one.
86
- * 10. Add optional files based on flags
87
- * 11. Install the new packages.
88
- * 12. Serve the new app.
89
- * 13. Wait for the server to start.
90
- * 14. Seed the database.
91
- * 15. Open the browser.
92
- */
93
- async run() {
94
- // * 1 Create a folder named after the first argument or ask for it.
95
- const { argv } = await this.parse(CreateManifest);
96
- let projectName = argv[0];
97
- // let isMonorepo: boolean = argv[1] === 'monorepo'
98
- const isMonorepo = false; // Hide this feature.
99
- if (!projectName) {
100
- projectName = await input({
101
- message: 'What name would you like to use for the new workspace?',
102
- validate: (input) => {
103
- if (!input.trim()) {
104
- return 'The name name cannot be empty';
105
- }
106
- // Check for invalid characters in The name names
107
- if (/[<>:"/\\|?*]/.test(input)) {
108
- return 'Folder name contains invalid characters';
109
- }
110
- return true;
111
- }
112
- });
113
- }
114
- // if (!isMonorepo) {
115
- // const projectType = await select({
116
- // message: 'What type of project would you like to develop?',
117
- // choices: [
118
- // {
119
- // name: 'A full-stack app (monorepo)',
120
- // value: 'monorepo',
121
- // description: 'Creates a monorepo with both "web" and "api" folders'
122
- // },
123
- // {
124
- // name: 'A standalone backend',
125
- // value: 'standalone',
126
- // description: 'Creates a backend-only project'
127
- // }
128
- // ]
129
- // })
130
- // isMonorepo = projectType === 'monorepo'
131
- // }
132
- projectName = slugify(projectName);
133
- const spinner = ora(`Creating your Manifest project in ${projectName} folder...`).start();
134
- const rootFolderPath = path.join(process.cwd(), projectName);
135
- // Check if the folder already exists
136
- if (fs.existsSync(rootFolderPath)) {
137
- spinner.fail(`Error: The "${rootFolderPath}" folder already exists in the current directory. Please find another name.`);
138
- process.exit(1);
139
- }
140
- fs.mkdirSync(rootFolderPath);
141
- let projectFolderPath;
142
- if (isMonorepo) {
143
- // If it's a monorepo, create a folder for the project.
144
- projectFolderPath = path.join(rootFolderPath, 'api');
145
- fs.mkdirSync(projectFolderPath);
146
- fs.mkdirSync(path.join(rootFolderPath, 'web'));
147
- }
148
- else {
149
- // If it's a standalone backend, use the root folder as the project folder.
150
- projectFolderPath = rootFolderPath;
151
- }
152
- const manifestFolderName = '.manifest';
153
- const initialFileName = 'manifest.yml';
154
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
155
- const assetFolderPath = path.join(__dirname, '..', '..', 'assets', isMonorepo ? 'monorepo' : 'standalone');
156
- // * 2. Create a folder with the name `.manifest` for compiled files.
157
- // Construct the folder path. This example creates the folder in the current working directory.
158
- const compiledFolderPath = path.join(projectFolderPath, manifestFolderName);
159
- // Create the folder
160
- fs.mkdirSync(compiledFolderPath);
161
- // * 3. Create a file with the name `manifest.yml`.
162
- const newFilePath = path.join(projectFolderPath, initialFileName);
163
- // Get the content of the file either remote or local.
164
- const { flags } = await this.parse(CreateManifest);
165
- const remoteBackendFile = flags.backendFile;
166
- const content = await getBackendFileContent(path.join(assetFolderPath, initialFileName), remoteBackendFile);
167
- // Write the content to the new file
168
- fs.writeFileSync(newFilePath, content);
169
- spinner.succeed();
170
- spinner.start('Creating package.json file...');
171
- // Update package.json file.
172
- const packagePath = path.join(projectFolderPath, 'package.json');
173
- const packageJson = JSON.parse(fs
174
- .readFileSync(path.join(assetFolderPath, 'api-package.json'), 'utf8')
175
- .replace('PROJECT_NAME', projectName));
176
- const manifestLatestVersion = await getLatestPackageVersion('manifest');
177
- fs.writeFileSync(packagePath, updatePackageJsonFile({
178
- fileContent: packageJson,
179
- newPackages: {
180
- manifest: `^${manifestLatestVersion}`
181
- },
182
- newScripts: {
183
- start: 'node node_modules/manifest/scripts/watch/watch.js',
184
- seed: 'node node_modules/manifest/dist/manifest/src/seed/scripts/seed.js'
185
- }
186
- }));
187
- if (isMonorepo) {
188
- // If it's a monorepo, also update the web package.json file and the root package.json file.
189
- const webPackagePath = path.join(rootFolderPath, 'web', 'package.json');
190
- fs.writeFileSync(webPackagePath, fs
191
- .readFileSync(path.join(assetFolderPath, 'web-package.json'), 'utf8')
192
- .replace('PROJECT_NAME', projectName));
193
- const rootPackagePath = path.join(rootFolderPath, 'package.json');
194
- fs.writeFileSync(rootPackagePath, fs
195
- .readFileSync(path.join(assetFolderPath, 'root-package.json'), 'utf8')
196
- .replace('PROJECT_NAME', projectName));
197
- }
198
- spinner.succeed();
199
- spinner.start('Adding settings...');
200
- // Update .vscode/extensions.json file.
201
- const vscodeDirPath = path.join(rootFolderPath, '.vscode');
202
- const extensionsFilePath = path.join(vscodeDirPath, 'extensions.json');
203
- let extensionsJson;
204
- // Ensure the `.vscode` Directory Exists
205
- if (!fs.existsSync(vscodeDirPath)) {
206
- fs.mkdirSync(vscodeDirPath);
207
- }
208
- // Read or Initialize `extensions.json`
209
- if (fs.existsSync(extensionsFilePath)) {
210
- extensionsJson = parse(fs.readFileSync(extensionsFilePath, 'utf8'));
211
- }
212
- else {
213
- extensionsJson = { recommendations: [] };
214
- }
215
- fs.writeFileSync(extensionsFilePath, updateExtensionJsonFile({
216
- extensions: ['redhat.vscode-yaml'],
217
- fileContent: extensionsJson
218
- }));
219
- // Update .vscode/extensions.json file.
220
- const settingsFilePath = path.join(vscodeDirPath, 'settings.json');
221
- let settingsJson;
222
- // Read or Initialize `settings.json`
223
- if (fs.existsSync(settingsFilePath)) {
224
- settingsJson = parse(fs.readFileSync(settingsFilePath, 'utf8'));
225
- }
226
- else {
227
- settingsJson = {};
228
- }
229
- fs.writeFileSync(settingsFilePath, updateSettingsJsonFile({
230
- fileContent: settingsJson,
231
- settings: {
232
- 'yaml.schemas': {
233
- 'https://schema.manifest.build/schema.json': '**/manifest.yml'
234
- }
235
- }
236
- }));
237
- // * 7. Update the .env file with the environment variables.
238
- const gitignorePath = path.join(projectFolderPath, '.gitignore');
239
- let gitignoreContent = '';
240
- if (fs.existsSync(gitignorePath)) {
241
- gitignoreContent = fs.readFileSync(gitignorePath, 'utf8');
242
- }
243
- const newGitignoreLines = [
244
- 'node_modules',
245
- '.env',
246
- 'public',
247
- '.manifest'
248
- ];
249
- newGitignoreLines.forEach((line) => {
250
- if (!gitignoreContent.includes(line)) {
251
- gitignoreContent += `\n${line}`;
252
- }
253
- });
254
- fs.writeFileSync(gitignorePath, gitignoreContent);
255
- spinner.succeed();
256
- // * 9. Add a README.md file if it doesn't exist.
257
- const readmeFilePath = path.join(rootFolderPath, 'README.md');
258
- if (!fs.existsSync(readmeFilePath)) {
259
- fs.writeFileSync(readmeFilePath, fs.readFileSync(path.join(assetFolderPath, 'README.md'), 'utf8'));
260
- }
261
- if (isMonorepo) {
262
- // If it's a monorepo, create a README.md file in the web folder and api folder (in addition to the root folder).
263
- const webReadmeFilePath = path.join(rootFolderPath, 'web', 'README.md');
264
- fs.writeFileSync(webReadmeFilePath, fs.readFileSync(path.join(assetFolderPath, 'web-readme.md'), 'utf8'));
265
- const apiReadmeFilePath = path.join(rootFolderPath, 'api', 'README.md');
266
- fs.writeFileSync(apiReadmeFilePath, fs.readFileSync(path.join(assetFolderPath, 'api-readme.md'), 'utf8'));
267
- }
268
- // * 10. Add optional files based on flags
269
- // Add rules for IDEs.
270
- if (flags.cursor) {
271
- spinner.start('Adding rules for Cursor IDE...');
272
- const cursorFolderPath = path.join(rootFolderPath, '.cursor', 'rules');
273
- const cursorFileName = 'manifest.mdc';
274
- fs.mkdirSync(cursorFolderPath, { recursive: true });
275
- let cursorFileContent;
276
- try {
277
- const response = await fetch('https://raw.githubusercontent.com/mnfst/rules/refs/heads/main/cursor/manifest.mdc');
278
- if (!response.ok) {
279
- throw new Error(`HTTP error! status: ${response.status}`);
280
- }
281
- cursorFileContent = await response.text();
282
- }
283
- catch (error) {
284
- console.error('Error fetching file:', error);
285
- throw error;
286
- }
287
- // Write the content to the new file
288
- fs.writeFileSync(path.join(cursorFolderPath, cursorFileName), cursorFileContent);
289
- spinner.succeed();
290
- }
291
- if (flags.copilot) {
292
- spinner.start('Adding rules for Copilot IDE...');
293
- const copilotFolderPath = path.join(rootFolderPath, '.github');
294
- const copilotFileName = 'copilot-instructions.md';
295
- fs.mkdirSync(copilotFolderPath, { recursive: true });
296
- let copilotFileContent;
297
- try {
298
- const response = await fetch('https://raw.githubusercontent.com/mnfst/rules/refs/heads/main/copilot/copilot-instructions.md');
299
- if (!response.ok) {
300
- throw new Error(`HTTP error! status: ${response.status}`);
301
- }
302
- copilotFileContent = await response.text();
303
- }
304
- catch (error) {
305
- console.error('Error fetching file:', error);
306
- throw error;
307
- }
308
- // Write the content to the new file
309
- fs.writeFileSync(path.join(copilotFolderPath, copilotFileName), copilotFileContent);
310
- spinner.succeed();
311
- }
312
- if (flags.windsurf) {
313
- spinner.start('Adding rules for WindSurf IDE...');
314
- const windsurfFolderPath = path.join(rootFolderPath, '.windsurf', 'rules');
315
- const windsurfFileName = 'manifest.md';
316
- fs.mkdirSync(windsurfFolderPath, { recursive: true });
317
- let windsurfFileContent;
318
- try {
319
- const response = await fetch('https://raw.githubusercontent.com/mnfst/rules/refs/heads/main/windsurf/manifest.md');
320
- if (!response.ok) {
321
- throw new Error(`HTTP error! status: ${response.status}`);
322
- }
323
- windsurfFileContent = await response.text();
324
- }
325
- catch (error) {
326
- console.error('Error fetching file:', error);
327
- throw error;
328
- }
329
- // Write the content to the new file
330
- fs.writeFileSync(path.join(windsurfFolderPath, windsurfFileName), windsurfFileContent);
331
- spinner.succeed();
332
- }
333
- // * 9. Install the new packages.
334
- spinner.start('Installing dependencies...');
335
- // Install deps.
336
- try {
337
- await execInDirectory(`npm install --silent`, projectName);
338
- }
339
- catch (error) {
340
- spinner.fail(`Execution error: ${error}`);
341
- }
342
- // Serve the new app.
343
- spinner.succeed();
344
- spinner.start('Adding environment variables...');
345
- // Add environment variables to .env file
346
- const envFilePath = path.join(projectFolderPath, '.env');
347
- const envJWTSecret = `TOKEN_SECRET_KEY=${crypto
348
- .randomBytes(32)
349
- .toString('hex')}`;
350
- let envContent;
351
- if (fs.existsSync(envFilePath)) {
352
- envContent = fs.readFileSync(envFilePath, 'utf8');
353
- envContent += `\n` + envJWTSecret;
354
- }
355
- else {
356
- envContent = envJWTSecret;
357
- }
358
- fs.writeFileSync(envFilePath, envContent);
359
- spinner.succeed();
360
- spinner.start('Building the database...');
361
- let serverProcess = null;
362
- try {
363
- // We run the manifest script to build the database in the background
364
- serverProcess = spawnInDirectory('npm', ['run', 'start'], projectName);
365
- // Wait for the server to be ready
366
- await this.waitForServerToBeReady();
367
- spinner.succeed();
368
- }
369
- catch (error) {
370
- spinner.fail(`Execution error: ${error}`);
371
- // If server failed to start, try to kill it
372
- if (serverProcess && serverProcess.pid) {
373
- try {
374
- await this.silentKill(serverProcess.pid);
375
- }
376
- catch {
377
- // Ignore errors when killing the process
378
- }
379
- }
380
- throw error;
381
- }
382
- spinner.start('Seeding initial data...');
383
- try {
384
- await execInDirectory(`npm run seed`, projectName);
385
- }
386
- catch (error) {
387
- spinner.fail(`Execution error: ${error}`);
388
- }
389
- spinner.succeed();
390
- console.log();
391
- console.log(chalk.bold('🎉 Manifest successfully installed !'));
392
- console.log();
393
- console.log('To start the server:');
394
- console.log();
395
- console.log(chalk.bold(` cd ${projectName}`));
396
- console.log(chalk.bold(' npm run start'));
397
- console.log();
398
- // Kill the background server process if it exists
399
- if (serverProcess && serverProcess.pid) {
400
- try {
401
- await this.silentKill(serverProcess.pid);
402
- }
403
- catch {
404
- // Ignore errors when killing the process
405
- }
406
- }
407
- process.exit();
408
- }
409
- /**
410
- * Check if the server is ready.
411
- *
412
- * @returns {Promise<boolean>} - Returns a promise that resolves to a boolean.
413
- *
414
- **/
415
- async isServerReady() {
416
- try {
417
- const response = await axios.get('http://localhost:1111/api/health', {
418
- timeout: 5000 // 5 second timeout
419
- });
420
- return response.status === 200;
421
- }
422
- catch {
423
- // Server is not ready yet
424
- return false;
425
- }
426
- }
427
- /**
428
- * Wait for the server to be ready.
429
- *
430
- * @returns a promise that resolves to void when the server is ready.
431
- *
432
- **/
433
- async waitForServerToBeReady() {
434
- let serverReady = false;
435
- let attempts = 0;
436
- const maxAttempts = 30; // 30 seconds timeout
437
- while (!serverReady && attempts < maxAttempts) {
438
- serverReady = await this.isServerReady();
439
- if (!serverReady) {
440
- attempts++;
441
- await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait 1s before retrying
442
- }
443
- }
444
- if (!serverReady) {
445
- throw new Error('Server failed to start within 30 seconds');
446
- }
447
- }
448
- /**
449
- * Transform a JSON with comments to a JSON without comments.
450
- *
451
- * @param jsonString - The JSON with comments.
452
- *
453
- * @returns the JSON without comments.
454
- *
455
- **/
456
- removeComments(jsonString) {
457
- return jsonString
458
- .replace(/\/\*[\s\S]*?\*\//g, '') // Remove multi-line comments
459
- .replace(/\/\/.*$/gm, ''); // Remove single-line comments
460
- }
461
- /**
462
- * Kill a process without logging an error if it fails.
463
- *
464
- * @param {number} pid - The process ID.
465
- * @returns {Promise<void>} - A promise that resolves when the process is killed.
466
- *
467
- */
468
- silentKill(pid) {
469
- return new Promise((resolve, reject) => {
470
- treeKill(pid, 'SIGKILL', (err) => {
471
- if (err) {
472
- reject(`Failed to kill process: ${err}`);
473
- }
474
- else {
475
- resolve();
476
- }
477
- });
478
- });
479
- }
480
- }
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export { run } from '@oclif/core';
package/dist/index.js DELETED
@@ -1 +0,0 @@
1
- export { run } from '@oclif/core';
@@ -1 +0,0 @@
1
- export declare const getBackendFileContent: (localPath: string, remotePath?: string) => Promise<string>;
@@ -1,21 +0,0 @@
1
- import * as fs from 'node:fs';
2
- export const getBackendFileContent = async (localPath, remotePath) => {
3
- // We use local default example backend file if remotePath is not provided.
4
- if (!remotePath) {
5
- return Promise.resolve(fs.readFileSync(localPath, 'utf8'));
6
- }
7
- else {
8
- try {
9
- const response = await fetch(remotePath);
10
- if (!response.ok) {
11
- throw new Error(`HTTP error! status: ${response.status}`);
12
- }
13
- const yamlContent = await response.text();
14
- return yamlContent;
15
- }
16
- catch (error) {
17
- console.error('Error fetching YAML:', error);
18
- throw error;
19
- }
20
- }
21
- };
@@ -1 +0,0 @@
1
- export declare const getLatestPackageVersion: (packageName: string) => Promise<string>;
@@ -1,5 +0,0 @@
1
- export const getLatestPackageVersion = async (packageName) => {
2
- const response = await fetch(`https://registry.npmjs.org/${packageName}`);
3
- const data = await response.json();
4
- return data['dist-tags'].latest;
5
- };
@@ -1,6 +0,0 @@
1
- export declare const updateExtensionJsonFile: ({ extensions, fileContent }: {
2
- extensions: string[];
3
- fileContent: {
4
- recommendations: string[];
5
- };
6
- }) => string;
@@ -1,8 +0,0 @@
1
- export const updateExtensionJsonFile = ({ extensions, fileContent }) => {
2
- extensions.forEach((extension) => {
3
- if (!fileContent.recommendations.includes(extension)) {
4
- fileContent.recommendations.push(extension);
5
- }
6
- });
7
- return JSON.stringify(fileContent, null, 2);
8
- };
@@ -1,18 +0,0 @@
1
- /**
2
- * Updates the package.json file with new packages and scripts.
3
- *
4
- * @param {Object} params - The parameters for updating the package.json file.
5
- * @param {JSON} params.fileContent - The current content of the package.json file.
6
- * @param {Record<string, string>} params.newPackages - An object where the keys are the names of the new packages and the values are the versions.
7
- * @param {Record<string, string>} params.newScripts - An object where the keys are the names of the new scripts and the values are the script commands.
8
- *
9
- * @returns {string} The updated content of the package.json file.
10
- */
11
- export declare const updatePackageJsonFile: ({ fileContent, newPackages, newScripts }: {
12
- fileContent: {
13
- scripts: Record<string, string>;
14
- dependencies: Record<string, string>;
15
- };
16
- newPackages: Record<string, string>;
17
- newScripts: Record<string, string>;
18
- }) => string;
@@ -1,21 +0,0 @@
1
- /**
2
- * Updates the package.json file with new packages and scripts.
3
- *
4
- * @param {Object} params - The parameters for updating the package.json file.
5
- * @param {JSON} params.fileContent - The current content of the package.json file.
6
- * @param {Record<string, string>} params.newPackages - An object where the keys are the names of the new packages and the values are the versions.
7
- * @param {Record<string, string>} params.newScripts - An object where the keys are the names of the new scripts and the values are the script commands.
8
- *
9
- * @returns {string} The updated content of the package.json file.
10
- */
11
- export const updatePackageJsonFile = ({ fileContent, newPackages, newScripts }) => {
12
- fileContent.scripts = {
13
- ...fileContent.scripts,
14
- ...newScripts
15
- };
16
- fileContent.dependencies = {
17
- ...fileContent.dependencies,
18
- ...newPackages
19
- };
20
- return JSON.stringify(fileContent, null, 2);
21
- };
@@ -1,4 +0,0 @@
1
- export declare const updateSettingsJsonFile: ({ fileContent, settings }: {
2
- fileContent: Record<string, unknown>;
3
- settings: Record<string, unknown>;
4
- }) => string;
@@ -1,6 +0,0 @@
1
- export const updateSettingsJsonFile = ({ fileContent, settings }) => {
2
- Object.keys(settings).forEach((key) => {
3
- fileContent[key] = settings[key];
4
- });
5
- return JSON.stringify(fileContent, null, 2);
6
- };
@@ -1 +0,0 @@
1
- export declare const slugify: (text: string) => string;
@@ -1,11 +0,0 @@
1
- export const slugify = (text) => {
2
- return text
3
- .toString() // Convert to string
4
- .normalize('NFD') // Normalize accents
5
- .replace(/[\u0300-\u036f]/g, '') // Remove accent marks
6
- .toLowerCase() // Convert to lowercase
7
- .replace(/[^a-z0-9\s-]/g, '') // Remove special characters (keep spaces and hyphens)
8
- .replace(/\s+/g, '-') // Replace spaces with hyphens
9
- .replace(/-+/g, '-') // Replace multiple hyphens with single hyphen
10
- .replace(/^-+|-+$/g, ''); // Remove leading/trailing hyphens
11
- };