@expressots/cli 1.7.1 → 1.8.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.
- package/README.md +8 -0
- package/bin/@types/config.d.ts +39 -39
- package/bin/@types/config.js +2 -2
- package/bin/@types/index.d.ts +1 -1
- package/bin/@types/index.js +17 -17
- package/bin/app.container.d.ts +1 -1
- package/bin/app.container.js +8 -8
- package/bin/cli.d.ts +2 -2
- package/bin/cli.js +38 -38
- package/bin/commands/__tests__/project.commands.spec.d.ts +1 -0
- package/bin/commands/__tests__/project.commands.spec.js +8 -0
- package/bin/commands/project.commands.d.ts +8 -8
- package/bin/commands/project.commands.js +137 -136
- package/bin/generate/cli.d.ts +4 -4
- package/bin/generate/cli.js +66 -66
- package/bin/generate/form.d.ts +20 -20
- package/bin/generate/form.js +30 -30
- package/bin/generate/index.d.ts +1 -1
- package/bin/generate/index.js +17 -17
- package/bin/generate/utils/command-utils.d.ts +123 -123
- package/bin/generate/utils/command-utils.js +314 -310
- package/bin/generate/utils/nonopininated-cmd.d.ts +9 -9
- package/bin/generate/utils/nonopininated-cmd.js +248 -248
- package/bin/generate/utils/opinionated-cmd.d.ts +11 -11
- package/bin/generate/utils/opinionated-cmd.js +481 -480
- package/bin/help/cli.d.ts +4 -4
- package/bin/help/cli.js +15 -15
- package/bin/help/form.d.ts +2 -2
- package/bin/help/form.js +28 -28
- package/bin/help/index.d.ts +1 -1
- package/bin/help/index.js +17 -2
- package/bin/index.d.ts +6 -4
- package/bin/index.js +22 -20
- package/bin/info/cli.d.ts +4 -4
- package/bin/info/cli.js +15 -15
- package/bin/info/form.d.ts +2 -2
- package/bin/info/form.js +36 -36
- package/bin/info/index.d.ts +1 -1
- package/bin/info/index.js +17 -17
- package/bin/new/cli.d.ts +4 -4
- package/bin/new/cli.js +65 -51
- package/bin/new/form.d.ts +2 -2
- package/bin/new/form.js +238 -213
- package/bin/new/index.d.ts +1 -1
- package/bin/new/index.js +17 -17
- package/bin/providers/cli.d.ts +4 -4
- package/bin/providers/cli.js +43 -38
- package/bin/providers/external/external.provider.d.ts +2 -0
- package/bin/providers/external/external.provider.js +49 -0
- package/bin/providers/index.d.ts +1 -1
- package/bin/providers/index.js +17 -17
- package/bin/providers/prisma/prisma.provider.d.ts +2 -2
- package/bin/providers/prisma/prisma.provider.js +272 -270
- package/bin/types.d.ts +1 -1
- package/bin/types.js +17 -17
- package/bin/utils/add-controller-to-module.d.ts +1 -1
- package/bin/utils/add-controller-to-module.js +46 -46
- package/bin/utils/add-module-to-container.d.ts +3 -3
- package/bin/utils/add-module-to-container.js +129 -129
- package/bin/utils/center-text.d.ts +2 -2
- package/bin/utils/center-text.js +10 -10
- package/bin/utils/cli-ui.d.ts +3 -3
- package/bin/utils/cli-ui.js +19 -19
- package/bin/utils/compiler.d.ts +15 -15
- package/bin/utils/compiler.js +93 -93
- package/bin/utils/find-folder.d.ts +5 -5
- package/bin/utils/find-folder.js +37 -37
- package/bin/utils/index.d.ts +1 -1
- package/bin/utils/index.js +17 -17
- package/bin/utils/verify-file-exists.d.ts +2 -2
- package/bin/utils/verify-file-exists.js +30 -30
- package/package.json +35 -31
package/bin/new/form.js
CHANGED
|
@@ -1,213 +1,238 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.projectForm = void 0;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const
|
|
9
|
-
const cli_progress_1 = require("cli-progress");
|
|
10
|
-
const degit_1 = __importDefault(require("degit"));
|
|
11
|
-
const inquirer_1 = __importDefault(require("inquirer"));
|
|
12
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
13
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
14
|
-
const center_text_1 = require("../utils/center-text");
|
|
15
|
-
const cli_ui_1 = require("../utils/cli-ui");
|
|
16
|
-
async function packageManagerInstall({ packageManager, directory, progressBar, }) {
|
|
17
|
-
return new Promise((resolve, reject) => {
|
|
18
|
-
const isWindows = process.platform === "win32";
|
|
19
|
-
const command = isWindows
|
|
20
|
-
? `${packageManager}.cmd`
|
|
21
|
-
: packageManager;
|
|
22
|
-
const installProcess = (0,
|
|
23
|
-
cwd: directory,
|
|
24
|
-
});
|
|
25
|
-
installProcess.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
{
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
{
|
|
125
|
-
type: "
|
|
126
|
-
name: "
|
|
127
|
-
message: "
|
|
128
|
-
default:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
await
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.projectForm = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const node_child_process_1 = require("node:child_process");
|
|
9
|
+
const cli_progress_1 = require("cli-progress");
|
|
10
|
+
const degit_1 = __importDefault(require("degit"));
|
|
11
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
12
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
13
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
14
|
+
const center_text_1 = require("../utils/center-text");
|
|
15
|
+
const cli_ui_1 = require("../utils/cli-ui");
|
|
16
|
+
async function packageManagerInstall({ packageManager, directory, progressBar, }) {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
const isWindows = process.platform === "win32";
|
|
19
|
+
const command = isWindows
|
|
20
|
+
? `${packageManager}.cmd`
|
|
21
|
+
: packageManager;
|
|
22
|
+
const installProcess = (0, node_child_process_1.spawn)(command, ["install"], {
|
|
23
|
+
cwd: directory,
|
|
24
|
+
});
|
|
25
|
+
installProcess.on("error", (error) => {
|
|
26
|
+
reject(new Error(`Failed to start subprocess: ${error.message}`));
|
|
27
|
+
});
|
|
28
|
+
installProcess.stdout?.on("data", (data) => {
|
|
29
|
+
const output = data.toString().trim();
|
|
30
|
+
const npmProgressMatch = output.match(/\[(\d+)\/(\d+)\] (?:npm )?([\w\s]+)\.{3}/);
|
|
31
|
+
if (npmProgressMatch) {
|
|
32
|
+
const [, current, total, task] = npmProgressMatch;
|
|
33
|
+
const progress = Math.round((parseInt(current) / parseInt(total)) * 100);
|
|
34
|
+
progressBar.update(progress, { doing: task });
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
progressBar.increment(5, { doing: output });
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
installProcess.on("close", (code) => {
|
|
41
|
+
if (code === 0) {
|
|
42
|
+
resolve("Installation Done!");
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
reject(new Error(`${packageManager} install exited with code ${code}`));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async function checkIfPackageManagerExists(packageManager) {
|
|
51
|
+
try {
|
|
52
|
+
(0, node_child_process_1.execSync)(`${packageManager} --version`);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
(0, cli_ui_1.printError)("Package manager not found!", packageManager);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function changePackageName({ directory, name, }) {
|
|
61
|
+
// Get the absolute path of the input directory parameter
|
|
62
|
+
const absDirPath = node_path_1.default.resolve(directory);
|
|
63
|
+
// Load the package.json file
|
|
64
|
+
const packageJsonPath = node_path_1.default.join(absDirPath, "package.json");
|
|
65
|
+
const fileContents = node_fs_1.default.readFileSync(packageJsonPath, "utf-8");
|
|
66
|
+
const packageJson = JSON.parse(fileContents);
|
|
67
|
+
// Change the name
|
|
68
|
+
packageJson.name = name;
|
|
69
|
+
// Save the package.json file
|
|
70
|
+
node_fs_1.default.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
71
|
+
}
|
|
72
|
+
function renameEnvFile(directory) {
|
|
73
|
+
try {
|
|
74
|
+
const envExamplePath = node_path_1.default.join(directory, ".env.example");
|
|
75
|
+
const envPath = node_path_1.default.join(directory, ".env");
|
|
76
|
+
if (!node_fs_1.default.existsSync(envExamplePath)) {
|
|
77
|
+
throw new Error(`File not found: ${envExamplePath}`);
|
|
78
|
+
}
|
|
79
|
+
node_fs_1.default.renameSync(envExamplePath, envPath);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
(0, cli_ui_1.printError)("Error renaming .env.example file", ".env.example to .env");
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
var Template;
|
|
87
|
+
(function (Template) {
|
|
88
|
+
Template["non-opinionated"] = "Non-Opinionated :: Allows users to choose where to scaffold resources, offering flexible project organization.";
|
|
89
|
+
Template["opinionated"] = "Opinionated :: Automatically scaffolds resources into a preset project structure. (Recommended)";
|
|
90
|
+
})(Template || (Template = {}));
|
|
91
|
+
const projectForm = async (projectName, args) => {
|
|
92
|
+
let answer;
|
|
93
|
+
const projName = projectName;
|
|
94
|
+
let packageManager;
|
|
95
|
+
let template;
|
|
96
|
+
let directory;
|
|
97
|
+
// Resolving the argument order problem
|
|
98
|
+
for (const arg of args) {
|
|
99
|
+
if (args.length >= 3) {
|
|
100
|
+
if (arg === "npm" ||
|
|
101
|
+
arg === "yarn" ||
|
|
102
|
+
arg === "pnpm" ||
|
|
103
|
+
arg === "bun") {
|
|
104
|
+
packageManager = arg;
|
|
105
|
+
}
|
|
106
|
+
else if (arg === "non-opinionated" || arg === "opinionated") {
|
|
107
|
+
template = arg;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
directory = arg;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (packageManager && template) {
|
|
115
|
+
answer = {
|
|
116
|
+
name: projectName,
|
|
117
|
+
packageManager: packageManager,
|
|
118
|
+
template: Template[template],
|
|
119
|
+
confirm: true,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
answer = await inquirer_1.default.prompt([
|
|
124
|
+
{
|
|
125
|
+
type: "input",
|
|
126
|
+
name: "name",
|
|
127
|
+
message: "Project name",
|
|
128
|
+
default: projectName,
|
|
129
|
+
transformer: (input) => {
|
|
130
|
+
return chalk_1.default.yellow(chalk_1.default.bold(input));
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
type: "list",
|
|
135
|
+
name: "packageManager",
|
|
136
|
+
message: "Package manager",
|
|
137
|
+
choices: ["npm", "yarn", "pnpm", "bun"],
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
type: "list",
|
|
141
|
+
name: "template",
|
|
142
|
+
message: "Select a template",
|
|
143
|
+
choices: [
|
|
144
|
+
`Opinionated :: Automatically scaffolds resources into a preset project structure. (${chalk_1.default.yellow("Recommended")})`,
|
|
145
|
+
"Non-Opinionated :: Allows users to choose where to scaffold resources, offering flexible project organization.",
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
type: "confirm",
|
|
150
|
+
name: "confirm",
|
|
151
|
+
message: "Do you want to create this project?",
|
|
152
|
+
default: true,
|
|
153
|
+
},
|
|
154
|
+
]);
|
|
155
|
+
}
|
|
156
|
+
if (directory) {
|
|
157
|
+
if (!node_fs_1.default.existsSync(node_path_1.default.join(directory, answer.name))) {
|
|
158
|
+
answer.name = node_path_1.default.join(directory, answer.name);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
(0, cli_ui_1.printError)("Directory already exists", directory);
|
|
162
|
+
process.exit(1);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// Hashmap of templates and their directories
|
|
166
|
+
const templates = {
|
|
167
|
+
"Non-Opinionated": "non_opinionated",
|
|
168
|
+
Opinionated: "opinionated",
|
|
169
|
+
};
|
|
170
|
+
if (answer.confirm) {
|
|
171
|
+
// Check if package manager is bun and OS is Windows
|
|
172
|
+
if (answer.packageManager === "bun" && process.platform === "win32") {
|
|
173
|
+
(0, cli_ui_1.printError)("bun is not supported on Windows. Please use", "npm, yarn or pnpm");
|
|
174
|
+
process.exit(1);
|
|
175
|
+
}
|
|
176
|
+
await checkIfPackageManagerExists(answer.packageManager);
|
|
177
|
+
console.log("\n");
|
|
178
|
+
const progressBar = new cli_progress_1.SingleBar({
|
|
179
|
+
format: "Progress |" +
|
|
180
|
+
chalk_1.default.green("{bar}") +
|
|
181
|
+
"| {percentage}% || {doing}",
|
|
182
|
+
hideCursor: true,
|
|
183
|
+
}, cli_progress_1.Presets.rect);
|
|
184
|
+
progressBar.start(100, 0, {
|
|
185
|
+
doing: "Cloning project",
|
|
186
|
+
});
|
|
187
|
+
const [_, template] = answer.template.match(/(.*) ::/);
|
|
188
|
+
try {
|
|
189
|
+
const emitter = (0, degit_1.default)(`expressots/expressots/templates/${templates[template]}`);
|
|
190
|
+
await emitter.clone(answer.name);
|
|
191
|
+
}
|
|
192
|
+
catch (err) {
|
|
193
|
+
console.log("\n");
|
|
194
|
+
(0, cli_ui_1.printError)("Project already exists or Folder is not empty", answer.name);
|
|
195
|
+
process.exit(1);
|
|
196
|
+
}
|
|
197
|
+
progressBar.update(50, {
|
|
198
|
+
doing: "Installing dependencies",
|
|
199
|
+
});
|
|
200
|
+
await packageManagerInstall({
|
|
201
|
+
packageManager: answer.packageManager,
|
|
202
|
+
directory: answer.name,
|
|
203
|
+
progressBar,
|
|
204
|
+
});
|
|
205
|
+
progressBar.update(90);
|
|
206
|
+
changePackageName({
|
|
207
|
+
directory: answer.name,
|
|
208
|
+
name: projName,
|
|
209
|
+
});
|
|
210
|
+
renameEnvFile(answer.name);
|
|
211
|
+
progressBar.update(100);
|
|
212
|
+
progressBar.stop();
|
|
213
|
+
console.log("\n");
|
|
214
|
+
console.log("🐎 Project", chalk_1.default.green(answer.name), "created successfully!");
|
|
215
|
+
console.log("🤙 Run the following commands to start the project:\n");
|
|
216
|
+
console.log(chalk_1.default.bold.gray(`$ cd ${answer.name}`));
|
|
217
|
+
switch (answer.packageManager) {
|
|
218
|
+
case "npm":
|
|
219
|
+
console.log(chalk_1.default.bold.gray("$ npm run dev"));
|
|
220
|
+
break;
|
|
221
|
+
case "yarn":
|
|
222
|
+
console.log(chalk_1.default.bold.gray("$ yarn dev"));
|
|
223
|
+
break;
|
|
224
|
+
case "pnpm":
|
|
225
|
+
console.log(chalk_1.default.bold.gray("$ pnpm run dev"));
|
|
226
|
+
break;
|
|
227
|
+
case "bun":
|
|
228
|
+
console.log(chalk_1.default.bold.gray("$ bun dev"));
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
console.log("\n");
|
|
232
|
+
console.log(chalk_1.default.bold.green((0, center_text_1.centerText)("Happy coding!")));
|
|
233
|
+
console.log(chalk_1.default.bold.gray((0, center_text_1.centerText)("Please consider donating to support the project.\n")));
|
|
234
|
+
console.log(chalk_1.default.bold.white((0, center_text_1.centerText)("💖 Sponsor: https://github.com/sponsors/expressots")));
|
|
235
|
+
console.log("\n");
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
exports.projectForm = projectForm;
|
package/bin/new/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./cli";
|
|
1
|
+
export * from "./cli";
|
package/bin/new/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./cli"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./cli"), exports);
|
package/bin/providers/cli.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandModule } from "yargs";
|
|
2
|
-
type CommandModuleArgs = {};
|
|
3
|
-
declare const generateProviders: () => CommandModule<CommandModuleArgs, any>;
|
|
4
|
-
export { generateProviders };
|
|
1
|
+
import { CommandModule } from "yargs";
|
|
2
|
+
type CommandModuleArgs = {};
|
|
3
|
+
declare const generateProviders: () => CommandModule<CommandModuleArgs, any>;
|
|
4
|
+
export { generateProviders };
|
package/bin/providers/cli.js
CHANGED
|
@@ -1,38 +1,43 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateProviders = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
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
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateProviders = void 0;
|
|
4
|
+
const external_provider_1 = require("./external/external.provider");
|
|
5
|
+
const prisma_provider_1 = require("./prisma/prisma.provider");
|
|
6
|
+
const generateProviders = () => {
|
|
7
|
+
return {
|
|
8
|
+
command: "add <provider> [library-version] [provider-version]",
|
|
9
|
+
describe: "Scaffold a new provider",
|
|
10
|
+
aliases: ["a"],
|
|
11
|
+
builder: (yargs) => {
|
|
12
|
+
yargs
|
|
13
|
+
.positional("provider", {
|
|
14
|
+
choices: ["prisma", "provider"],
|
|
15
|
+
describe: "The provider to add to the project",
|
|
16
|
+
type: "string",
|
|
17
|
+
alias: "p",
|
|
18
|
+
})
|
|
19
|
+
.option("library-version", {
|
|
20
|
+
describe: "The library version to install",
|
|
21
|
+
type: "string",
|
|
22
|
+
default: "latest",
|
|
23
|
+
alias: "v",
|
|
24
|
+
})
|
|
25
|
+
.option("provider-version", {
|
|
26
|
+
describe: "The version of the provider to install",
|
|
27
|
+
type: "string",
|
|
28
|
+
default: "latest",
|
|
29
|
+
alias: "vp",
|
|
30
|
+
});
|
|
31
|
+
return yargs;
|
|
32
|
+
},
|
|
33
|
+
handler: async ({ provider, libraryVersion, providerVersion }) => {
|
|
34
|
+
if (provider === "prisma") {
|
|
35
|
+
await (0, prisma_provider_1.prismaProvider)(libraryVersion, providerVersion);
|
|
36
|
+
}
|
|
37
|
+
else if (provider === "provider") {
|
|
38
|
+
await (0, external_provider_1.externalProvider)();
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
exports.generateProviders = generateProviders;
|