@suronai/cli 0.1.20 → 0.1.21
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/package.json +1 -1
- package/src/commands/init.js +12 -12
package/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -154,8 +154,8 @@ function sanitiseName(name) {
|
|
|
154
154
|
* CJS: require("dotenv").config();
|
|
155
155
|
*
|
|
156
156
|
* Replaces with the correct form based on the project type:
|
|
157
|
-
* ESM: import {
|
|
158
|
-
* CJS: const {
|
|
157
|
+
* ESM: import { config } from "@suronai/sdk"; await config();
|
|
158
|
+
* CJS: const { config } = require("@suronai/sdk"); await config();
|
|
159
159
|
*
|
|
160
160
|
* @param {string} cwd
|
|
161
161
|
* @param {boolean} isEsm
|
|
@@ -205,11 +205,11 @@ async function patchEntryPoint(cwd, isEsm) {
|
|
|
205
205
|
console.log(" " + c.red("-") + " " + c.dim(match[0].replace(/\n/g, "\n - ")));
|
|
206
206
|
console.log(" " + c.dim("With:"));
|
|
207
207
|
if (isEsm) {
|
|
208
|
-
console.log(" " + c.green("+") + " " + c.cyan("import") + " {
|
|
209
|
-
console.log(" " + c.green("+") + " " + c.cyan("await") + "
|
|
208
|
+
console.log(" " + c.green("+") + " " + c.cyan("import") + " { config } from " + c.green("'@suronai/sdk'"));
|
|
209
|
+
console.log(" " + c.green("+") + " " + c.cyan("await") + " config()");
|
|
210
210
|
} else {
|
|
211
|
-
console.log(" " + c.green("+") + " const {
|
|
212
|
-
console.log(" " + c.green("+") + " " + c.cyan("await") + "
|
|
211
|
+
console.log(" " + c.green("+") + " const { config } = " + c.cyan("require") + "(" + c.green("'@suronai/sdk'") + ")");
|
|
212
|
+
console.log(" " + c.green("+") + " " + c.cyan("await") + " config()");
|
|
213
213
|
}
|
|
214
214
|
console.log();
|
|
215
215
|
|
|
@@ -224,8 +224,8 @@ async function patchEntryPoint(cwd, isEsm) {
|
|
|
224
224
|
|
|
225
225
|
// Perform the replacement
|
|
226
226
|
const replacement = isEsm
|
|
227
|
-
? `import {
|
|
228
|
-
: `const {
|
|
227
|
+
? `import { config } from '@suronai/sdk';\nawait config();`
|
|
228
|
+
: `const { config } = require('@suronai/sdk');\nawait config();`;
|
|
229
229
|
|
|
230
230
|
const patched = src.replace(pattern, replacement);
|
|
231
231
|
|
|
@@ -242,11 +242,11 @@ async function patchEntryPoint(cwd, isEsm) {
|
|
|
242
242
|
/** @param {boolean} isEsm */
|
|
243
243
|
function printSnippet(isEsm) {
|
|
244
244
|
if (isEsm) {
|
|
245
|
-
console.log(" " + c.cyan("import") + " {
|
|
246
|
-
console.log(" " + c.cyan("await") + "
|
|
245
|
+
console.log(" " + c.cyan("import") + " { config } from " + c.green("'@suronai/sdk'"));
|
|
246
|
+
console.log(" " + c.cyan("await") + " config()");
|
|
247
247
|
} else {
|
|
248
|
-
console.log(" const {
|
|
249
|
-
console.log(" " + c.cyan("await") + "
|
|
248
|
+
console.log(" const { config } = " + c.cyan("require") + "(" + c.green("'@suronai/sdk'") + ")");
|
|
249
|
+
console.log(" " + c.cyan("await") + " config()");
|
|
250
250
|
}
|
|
251
251
|
console.log();
|
|
252
252
|
}
|