mango-cms 0.1.24 → 0.1.25
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/cli.js +74 -5
- package/default/config/config/settings.json +1 -2
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -10,18 +10,33 @@ const AdmZip = require('adm-zip');
|
|
|
10
10
|
|
|
11
11
|
const program = new Command();
|
|
12
12
|
|
|
13
|
-
// Helper function to download and extract src
|
|
13
|
+
// Helper function to download and extract versioned src zip file
|
|
14
14
|
async function ensureSrcExists(mangoCmsRoot) {
|
|
15
15
|
const srcDir = path.join(mangoCmsRoot, 'src');
|
|
16
16
|
if (!fs.existsSync(srcDir)) {
|
|
17
|
-
|
|
17
|
+
// Get the package version
|
|
18
|
+
const packageJsonPath = path.join(mangoCmsRoot, 'package.json');
|
|
19
|
+
let version = '0.1.24'; // Default fallback version
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
23
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
24
|
+
version = packageJson.version;
|
|
25
|
+
}
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.log('Error reading package.json:', error.message);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const zipFileName = `src-v${version}.zip`;
|
|
31
|
+
console.log(`Downloading Mango CMS source files (version ${version})...`);
|
|
32
|
+
|
|
18
33
|
const response = await axios({
|
|
19
34
|
method: 'get',
|
|
20
|
-
url:
|
|
35
|
+
url: `https://mango-cms.s3.amazonaws.com/${zipFileName}`,
|
|
21
36
|
responseType: 'arraybuffer'
|
|
22
37
|
});
|
|
23
38
|
|
|
24
|
-
const tempZipPath = path.join(mangoCmsRoot,
|
|
39
|
+
const tempZipPath = path.join(mangoCmsRoot, zipFileName);
|
|
25
40
|
fs.writeFileSync(tempZipPath, response.data);
|
|
26
41
|
|
|
27
42
|
console.log('Extracting source files...');
|
|
@@ -30,7 +45,7 @@ async function ensureSrcExists(mangoCmsRoot) {
|
|
|
30
45
|
|
|
31
46
|
// Clean up the zip file
|
|
32
47
|
fs.unlinkSync(tempZipPath);
|
|
33
|
-
console.log(
|
|
48
|
+
console.log(`Source files (version ${version}) installed successfully.`);
|
|
34
49
|
}
|
|
35
50
|
}
|
|
36
51
|
|
|
@@ -320,4 +335,58 @@ program
|
|
|
320
335
|
}
|
|
321
336
|
});
|
|
322
337
|
|
|
338
|
+
program
|
|
339
|
+
.command('update')
|
|
340
|
+
.description('Update Mango CMS source files to the latest version')
|
|
341
|
+
.action(async () => {
|
|
342
|
+
try {
|
|
343
|
+
// Path to @mango-cms/core inside node_modules
|
|
344
|
+
const cmsPackagePath = path.resolve(__dirname);
|
|
345
|
+
|
|
346
|
+
// Get the package version
|
|
347
|
+
const packageJsonPath = path.join(cmsPackagePath, 'package.json');
|
|
348
|
+
let version = '0.1.24'; // Default fallback version
|
|
349
|
+
|
|
350
|
+
try {
|
|
351
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
352
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
353
|
+
version = packageJson.version;
|
|
354
|
+
}
|
|
355
|
+
} catch (error) {
|
|
356
|
+
console.log('Error reading package.json:', error.message);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// Force remove existing src directory
|
|
360
|
+
const srcDir = path.join(cmsPackagePath, 'src');
|
|
361
|
+
if (fs.existsSync(srcDir)) {
|
|
362
|
+
console.log('Removing existing source files...');
|
|
363
|
+
fs.removeSync(srcDir);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const zipFileName = `src-v${version}.zip`;
|
|
367
|
+
console.log(`Downloading Mango CMS source files (version ${version})...`);
|
|
368
|
+
|
|
369
|
+
const response = await axios({
|
|
370
|
+
method: 'get',
|
|
371
|
+
url: `https://mango-cms.s3.amazonaws.com/${zipFileName}`,
|
|
372
|
+
responseType: 'arraybuffer'
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
const tempZipPath = path.join(cmsPackagePath, zipFileName);
|
|
376
|
+
fs.writeFileSync(tempZipPath, response.data);
|
|
377
|
+
|
|
378
|
+
console.log('Extracting source files...');
|
|
379
|
+
const zip = new AdmZip(tempZipPath);
|
|
380
|
+
zip.extractAllTo(cmsPackagePath, true);
|
|
381
|
+
|
|
382
|
+
// Clean up the zip file
|
|
383
|
+
fs.unlinkSync(tempZipPath);
|
|
384
|
+
console.log(`Source files (version ${version}) updated successfully.`);
|
|
385
|
+
|
|
386
|
+
} catch (error) {
|
|
387
|
+
console.error('Error updating Mango CMS source files:', error.message);
|
|
388
|
+
process.exit(1);
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
|
|
323
392
|
program.parse(process.argv);
|