ultimate-jekyll-manager 0.0.1 → 0.0.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/LICENSE +1 -1
- package/dist/commands/i.js +44 -0
- package/dist/commands/setup.js +34 -3
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { execute } = require('node-powertools');
|
|
4
|
+
|
|
5
|
+
// Load package
|
|
6
|
+
const package = require('../../package.json');
|
|
7
|
+
const project = require(path.join(process.cwd(), 'package.json'));
|
|
8
|
+
|
|
9
|
+
module.exports = async function (options) {
|
|
10
|
+
console.log(`Welcome to Ultimate Jekyll v${package.version}!`);
|
|
11
|
+
|
|
12
|
+
// Log
|
|
13
|
+
console.log('options:', options);
|
|
14
|
+
console.log('project:', project);
|
|
15
|
+
console.log('project:', project);
|
|
16
|
+
|
|
17
|
+
// Get type
|
|
18
|
+
const type = options._[1] || 'prod';
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
// Install production
|
|
22
|
+
if (['prod', 'p', 'production'].includes(type)) {
|
|
23
|
+
await install('npm uninstall ultimate-jekyll-manager');
|
|
24
|
+
await install('npm install ultimate-jekyll-manager@latest --save-dev');
|
|
25
|
+
|
|
26
|
+
return console.log('Production installation complete.');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Install development
|
|
30
|
+
if (['dev', 'd', 'development', 'local', 'l'].includes(type)) {
|
|
31
|
+
await install('npm uninstall ultimate-jekyll-manager');
|
|
32
|
+
await install('npm install ../../ITW-Creative-Works/ultimate-jekyll-manager --save-dev');
|
|
33
|
+
|
|
34
|
+
return console.log('Development installation complete.');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.error(`Error during the prompt: ${e.message}`);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
function install(command) {
|
|
43
|
+
return execute(command, { log: true });
|
|
44
|
+
}
|
package/dist/commands/setup.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Libraries
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const { gte
|
|
3
|
+
const { gte } = require('semver');
|
|
4
4
|
const { execute } = require('node-powertools');
|
|
5
5
|
const NPM = require('npm-api');
|
|
6
6
|
|
|
@@ -22,6 +22,9 @@ module.exports = async function (options) {
|
|
|
22
22
|
// Run the setup
|
|
23
23
|
await ensurePeerDependencies();
|
|
24
24
|
|
|
25
|
+
// Check which locality we are using
|
|
26
|
+
checkLocality();
|
|
27
|
+
|
|
25
28
|
} catch (e) {
|
|
26
29
|
console.error(`Error during the prompt: ${e.message}`);
|
|
27
30
|
}
|
|
@@ -30,6 +33,7 @@ module.exports = async function (options) {
|
|
|
30
33
|
async function updateManager() {
|
|
31
34
|
const npm = new NPM();
|
|
32
35
|
|
|
36
|
+
// Get the latest version
|
|
33
37
|
const latestVersion = await npm.repo('ultimate-jekyll-manager')
|
|
34
38
|
.package()
|
|
35
39
|
.then((pkg) => {
|
|
@@ -37,10 +41,27 @@ async function updateManager() {
|
|
|
37
41
|
}, (e) => {
|
|
38
42
|
return '0.0.0';
|
|
39
43
|
});
|
|
44
|
+
const installedVersion = project.dependencies['ultimate-jekyll-manager'];
|
|
45
|
+
|
|
46
|
+
// Quit if local
|
|
47
|
+
if (installedVersion.startsWith('file:')) {
|
|
48
|
+
// return console.log('Local version detected. Skipping update check.');
|
|
49
|
+
}
|
|
40
50
|
|
|
41
|
-
//
|
|
42
|
-
|
|
51
|
+
// Clean the versions
|
|
52
|
+
const cleanInstalledVersion = clean(installedVersion) || '0.0.0';
|
|
53
|
+
const cleanLatestVersion = clean(latestVersion);
|
|
43
54
|
|
|
55
|
+
// Log
|
|
56
|
+
console.log('Installed Version:', cleanInstalledVersion);
|
|
57
|
+
console.log('Latest Version:', cleanLatestVersion);
|
|
58
|
+
|
|
59
|
+
// Check if we need to update
|
|
60
|
+
if (gte(cleanInstalledVersion, cleanLatestVersion)) {
|
|
61
|
+
return console.log('Ultimate Jekyll Manager is up-to-date.');
|
|
62
|
+
} else {
|
|
63
|
+
await install('ultimate-jekyll-manager', latestVersion);
|
|
64
|
+
}
|
|
44
65
|
}
|
|
45
66
|
|
|
46
67
|
async function ensurePeerDependencies() {
|
|
@@ -65,6 +86,16 @@ async function ensurePeerDependencies() {
|
|
|
65
86
|
}
|
|
66
87
|
}
|
|
67
88
|
|
|
89
|
+
function checkLocality() {
|
|
90
|
+
const installedVersion = project.dependencies['ultimate-jekyll-manager'];
|
|
91
|
+
|
|
92
|
+
if (installedVersion.startsWith('file:')) {
|
|
93
|
+
console.warn('⚠️⚠️⚠️ You are using the local version of Ultimate Jekyll Manager. This WILL NOT WORK when published. ⚠️⚠️⚠️');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const clean = (version) => version.replace(/^[^\d]+/, '');
|
|
98
|
+
|
|
68
99
|
function install(package, version) {
|
|
69
100
|
// Default to latest
|
|
70
101
|
version || 'latest';
|