create-manifest 1.1.4 → 1.1.5
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/assets/backend.yml +9 -0
- package/assets/default-package.json +2 -2
- package/dist/commands/index.js +13 -6
- package/dist/utils/helpers.d.ts +1 -0
- package/dist/utils/helpers.js +11 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/assets/backend.yml
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
# This is a sample file for a backend.yml manifest backend.
|
|
2
|
+
# Read more about the manifest format here: https:/manifest.build/docs
|
|
3
|
+
|
|
1
4
|
name: My pet app 🐾
|
|
2
5
|
entities:
|
|
3
6
|
Owner:
|
|
@@ -12,6 +15,9 @@ entities:
|
|
|
12
15
|
- { name: birthdate, type: date }
|
|
13
16
|
belongsTo:
|
|
14
17
|
- Owner
|
|
18
|
+
policies:
|
|
19
|
+
read:
|
|
20
|
+
- access: public
|
|
15
21
|
|
|
16
22
|
Homepage:
|
|
17
23
|
nameSingular: Home content
|
|
@@ -20,3 +26,6 @@ entities:
|
|
|
20
26
|
- title
|
|
21
27
|
- { name: description, type: richText }
|
|
22
28
|
- { name: cover, type: image }
|
|
29
|
+
policies:
|
|
30
|
+
read:
|
|
31
|
+
- access: public
|
package/dist/commands/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import { exec as execCp } from 'node:child_process';
|
|
4
|
-
import * as crypto from 'node:crypto';
|
|
5
4
|
import * as fs from 'node:fs';
|
|
5
|
+
import * as crypto from 'node:crypto';
|
|
6
6
|
import * as path from 'node:path';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
8
|
import { promisify } from 'node:util';
|
|
@@ -15,6 +15,8 @@ import { updateSettingsJsonFile } from '../utils/UpdateSettingsJsonFile.js';
|
|
|
15
15
|
import { getLatestPackageVersion } from '../utils/GetLatestPackageVersion.js';
|
|
16
16
|
import { getBackendFileContent } from '../utils/GetBackendFileContent.js';
|
|
17
17
|
import { input } from '@inquirer/prompts';
|
|
18
|
+
import { slugify } from '../utils/helpers.js';
|
|
19
|
+
import chalk from 'chalk';
|
|
18
20
|
const exec = promisify(execCp);
|
|
19
21
|
export default class CreateManifest extends Command {
|
|
20
22
|
static description = 'Create a new Manifest project with the default files and folders.';
|
|
@@ -53,7 +55,7 @@ export default class CreateManifest extends Command {
|
|
|
53
55
|
async run() {
|
|
54
56
|
// * 1 Create a folder named after the first argument or ask for it.
|
|
55
57
|
const { argv } = await this.parse(CreateManifest);
|
|
56
|
-
let projectName = argv[0];
|
|
58
|
+
let projectName = slugify(argv[0]);
|
|
57
59
|
if (!projectName) {
|
|
58
60
|
projectName = await input({
|
|
59
61
|
message: 'What name would you like to use for the new workspace?',
|
|
@@ -104,7 +106,9 @@ export default class CreateManifest extends Command {
|
|
|
104
106
|
packageJson = parse(fs.readFileSync(packagePath, 'utf8'));
|
|
105
107
|
}
|
|
106
108
|
else {
|
|
107
|
-
packageJson = JSON.parse(fs
|
|
109
|
+
packageJson = JSON.parse(fs
|
|
110
|
+
.readFileSync(path.join(assetFolderPath, 'default-package.json'), 'utf8')
|
|
111
|
+
.replace('PROJECT_NAME', projectName));
|
|
108
112
|
}
|
|
109
113
|
const manifestLatestVersion = await getLatestPackageVersion('manifest');
|
|
110
114
|
fs.writeFileSync(packagePath, updatePackageJsonFile({
|
|
@@ -207,7 +211,7 @@ export default class CreateManifest extends Command {
|
|
|
207
211
|
spinner.start('Install dependencies...');
|
|
208
212
|
// Install deps.
|
|
209
213
|
try {
|
|
210
|
-
await exec(
|
|
214
|
+
await exec(`cd ${projectName} && npm install --silent`);
|
|
211
215
|
}
|
|
212
216
|
catch (error) {
|
|
213
217
|
spinner.fail(`Execution error: ${error}`);
|
|
@@ -250,9 +254,12 @@ export default class CreateManifest extends Command {
|
|
|
250
254
|
}
|
|
251
255
|
spinner.succeed();
|
|
252
256
|
console.log();
|
|
253
|
-
console.log('🎉 Manifest successfully installed !');
|
|
257
|
+
console.log(chalk.bold('🎉 Manifest successfully installed !'));
|
|
258
|
+
console.log();
|
|
259
|
+
console.log('To start the server:');
|
|
254
260
|
console.log();
|
|
255
|
-
console.log(
|
|
261
|
+
console.log(chalk.bold(` cd ${projectName}`));
|
|
262
|
+
console.log(chalk.bold(' npm run manifest'));
|
|
256
263
|
console.log();
|
|
257
264
|
await this.silentKill(serveTask?.child?.pid || 0);
|
|
258
265
|
process.exit();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const slugify: (text: string) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
};
|
package/oclif.manifest.json
CHANGED