create-manifest 1.1.3 → 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.d.ts +2 -1
- package/dist/commands/index.js +17 -9
- package/dist/utils/helpers.d.ts +1 -0
- package/dist/utils/helpers.js +11 -0
- package/oclif.manifest.json +35 -2
- package/package.json +5 -3
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.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
export
|
|
2
|
+
export default class CreateManifest extends Command {
|
|
3
|
+
static description: string;
|
|
3
4
|
static args: {
|
|
4
5
|
firstArg: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
5
6
|
};
|
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,8 +15,11 @@ 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
|
-
export class
|
|
21
|
+
export default class CreateManifest extends Command {
|
|
22
|
+
static description = 'Create a new Manifest project with the default files and folders.';
|
|
20
23
|
static args = {
|
|
21
24
|
firstArg: Args.string({
|
|
22
25
|
name: 'name',
|
|
@@ -51,8 +54,8 @@ export class MyCommand extends Command {
|
|
|
51
54
|
*/
|
|
52
55
|
async run() {
|
|
53
56
|
// * 1 Create a folder named after the first argument or ask for it.
|
|
54
|
-
const { argv } = await this.parse(
|
|
55
|
-
let projectName = argv[0];
|
|
57
|
+
const { argv } = await this.parse(CreateManifest);
|
|
58
|
+
let projectName = slugify(argv[0]);
|
|
56
59
|
if (!projectName) {
|
|
57
60
|
projectName = await input({
|
|
58
61
|
message: 'What name would you like to use for the new workspace?',
|
|
@@ -89,7 +92,7 @@ export class MyCommand extends Command {
|
|
|
89
92
|
// Path where the new file should be created
|
|
90
93
|
const newFilePath = path.join(manifestFolderPath, initialFileName);
|
|
91
94
|
// Get the content of the file either remote or local.
|
|
92
|
-
const { flags } = await this.parse(
|
|
95
|
+
const { flags } = await this.parse(CreateManifest);
|
|
93
96
|
const remoteBackendFile = flags.backendFile;
|
|
94
97
|
const content = await getBackendFileContent(path.join(assetFolderPath, initialFileName), remoteBackendFile);
|
|
95
98
|
// Write the content to the new file
|
|
@@ -103,7 +106,9 @@ export class MyCommand extends Command {
|
|
|
103
106
|
packageJson = parse(fs.readFileSync(packagePath, 'utf8'));
|
|
104
107
|
}
|
|
105
108
|
else {
|
|
106
|
-
packageJson = JSON.parse(fs
|
|
109
|
+
packageJson = JSON.parse(fs
|
|
110
|
+
.readFileSync(path.join(assetFolderPath, 'default-package.json'), 'utf8')
|
|
111
|
+
.replace('PROJECT_NAME', projectName));
|
|
107
112
|
}
|
|
108
113
|
const manifestLatestVersion = await getLatestPackageVersion('manifest');
|
|
109
114
|
fs.writeFileSync(packagePath, updatePackageJsonFile({
|
|
@@ -206,7 +211,7 @@ export class MyCommand extends Command {
|
|
|
206
211
|
spinner.start('Install dependencies...');
|
|
207
212
|
// Install deps.
|
|
208
213
|
try {
|
|
209
|
-
await exec(
|
|
214
|
+
await exec(`cd ${projectName} && npm install --silent`);
|
|
210
215
|
}
|
|
211
216
|
catch (error) {
|
|
212
217
|
spinner.fail(`Execution error: ${error}`);
|
|
@@ -249,9 +254,12 @@ export class MyCommand extends Command {
|
|
|
249
254
|
}
|
|
250
255
|
spinner.succeed();
|
|
251
256
|
console.log();
|
|
252
|
-
console.log('🎉 Manifest successfully installed !');
|
|
257
|
+
console.log(chalk.bold('🎉 Manifest successfully installed !'));
|
|
258
|
+
console.log();
|
|
259
|
+
console.log('To start the server:');
|
|
253
260
|
console.log();
|
|
254
|
-
console.log(
|
|
261
|
+
console.log(chalk.bold(` cd ${projectName}`));
|
|
262
|
+
console.log(chalk.bold(' npm run manifest'));
|
|
255
263
|
console.log();
|
|
256
264
|
await this.silentKill(serveTask?.child?.pid || 0);
|
|
257
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
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
{
|
|
2
|
-
"commands": {
|
|
3
|
-
|
|
2
|
+
"commands": {
|
|
3
|
+
"Symbol(SINGLE_COMMAND_CLI)": {
|
|
4
|
+
"aliases": [],
|
|
5
|
+
"args": {
|
|
6
|
+
"firstArg": {
|
|
7
|
+
"description": "The name for the new workspace and the initial project. It will be used for the root directory.",
|
|
8
|
+
"name": "firstArg"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"description": "Create a new Manifest project with the default files and folders.",
|
|
12
|
+
"flags": {
|
|
13
|
+
"backendFile": {
|
|
14
|
+
"name": "backendFile",
|
|
15
|
+
"summary": "The remote file to use as a template for the backend.yml file. If not provided, the default file will be used.",
|
|
16
|
+
"hasDynamicHelp": false,
|
|
17
|
+
"multiple": false,
|
|
18
|
+
"type": "option"
|
|
19
|
+
},
|
|
20
|
+
"cursor": {
|
|
21
|
+
"name": "cursor",
|
|
22
|
+
"allowNo": false,
|
|
23
|
+
"type": "boolean"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"hasDynamicHelp": false,
|
|
27
|
+
"hiddenAliases": [],
|
|
28
|
+
"id": "Symbol(SINGLE_COMMAND_CLI)",
|
|
29
|
+
"pluginAlias": "create-manifest",
|
|
30
|
+
"pluginName": "create-manifest",
|
|
31
|
+
"pluginType": "core",
|
|
32
|
+
"strict": true,
|
|
33
|
+
"enableJsonFlag": false
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"version": "1.1.5"
|
|
4
37
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-manifest",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"author": "Manifest",
|
|
5
5
|
"description": "Create a new Manifest backend",
|
|
6
6
|
"homepage": "https://manifest.build",
|
|
@@ -20,8 +20,10 @@
|
|
|
20
20
|
"oclif": {
|
|
21
21
|
"bin": "create-manifest",
|
|
22
22
|
"dirname": "create-manifest",
|
|
23
|
-
"
|
|
24
|
-
|
|
23
|
+
"commands": {
|
|
24
|
+
"strategy": "single",
|
|
25
|
+
"target": "./dist/commands/index.js"
|
|
26
|
+
}
|
|
25
27
|
},
|
|
26
28
|
"plugins": [
|
|
27
29
|
"@oclif/plugin-help",
|