slicejs-cli 3.7.0 → 3.7.2
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/commands/init/init.js
CHANGED
|
@@ -230,7 +230,7 @@ export default async function initializeProject(options = {}) {
|
|
|
230
230
|
const srcDir = path.join(sliceBaseDir, 'src');
|
|
231
231
|
|
|
232
232
|
try {
|
|
233
|
-
if (fs.existsSync(destinationApi)) throw new Error(`
|
|
233
|
+
if (fs.existsSync(path.join(destinationApi, 'index.js'))) throw new Error(`api/index.js already exists: ${path.join(destinationApi, 'index.js')}`);
|
|
234
234
|
if (fs.existsSync(destinationSrc)) throw new Error(`The "src" directory already exists: ${destinationSrc}`);
|
|
235
235
|
} catch (error) {
|
|
236
236
|
Print.error('Validating destination directories:', error.message);
|
|
@@ -238,14 +238,16 @@ export default async function initializeProject(options = {}) {
|
|
|
238
238
|
return;
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
// 1. COPY
|
|
242
|
-
const apiSpinner = ora('
|
|
241
|
+
// 1. COPY ONLY api/index.js — el resto se importa desde el paquete
|
|
242
|
+
const apiSpinner = ora('Creating api/index.js...').start();
|
|
243
243
|
try {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
244
|
+
const srcIndex = path.join(apiDir, 'index.js');
|
|
245
|
+
if (!fs.existsSync(srcIndex)) throw new Error(`api/index.js not found: ${srcIndex}`);
|
|
246
|
+
await fs.ensureDir(destinationApi);
|
|
247
|
+
await fs.copy(srcIndex, path.join(destinationApi, 'index.js'));
|
|
248
|
+
apiSpinner.succeed('api/index.js created successfully');
|
|
247
249
|
} catch (error) {
|
|
248
|
-
apiSpinner.fail('Error
|
|
250
|
+
apiSpinner.fail('Error creating api/index.js');
|
|
249
251
|
Print.error(error.message);
|
|
250
252
|
console.error(error.stack);
|
|
251
253
|
return;
|