@ruebenfox/liquefaction 1.0.4 → 1.0.5
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/bin/cli.js +0 -6
- package/package.json +4 -3
- package/src/commands/add.js +25 -0
package/bin/cli.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const { program } = require('commander');
|
|
3
3
|
const addAction = require('../src/commands/add');
|
|
4
|
-
const removeAction = require('../src/commands/remove');
|
|
5
4
|
|
|
6
5
|
program
|
|
7
6
|
.version('1.0.0')
|
|
@@ -12,9 +11,4 @@ program
|
|
|
12
11
|
.description('Install a component from the library')
|
|
13
12
|
.action(addAction);
|
|
14
13
|
|
|
15
|
-
program
|
|
16
|
-
.command('remove <name>')
|
|
17
|
-
.description('Remove a component and its assets')
|
|
18
|
-
.action(removeAction);
|
|
19
|
-
|
|
20
14
|
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ruebenfox/liquefaction",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"bin": {
|
|
5
5
|
"liq": "./bin/cli.js"
|
|
6
6
|
},
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"components",
|
|
11
11
|
"registry.json",
|
|
12
|
-
"bin"
|
|
12
|
+
"bin",
|
|
13
|
+
"src"
|
|
13
14
|
],
|
|
14
15
|
"publishConfig": {
|
|
15
16
|
"access": "public"
|
|
@@ -23,4 +24,4 @@
|
|
|
23
24
|
"commander": "^14.0.2",
|
|
24
25
|
"fs-extra": "^11.3.3"
|
|
25
26
|
}
|
|
26
|
-
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const fs = require('fs-extra');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const libRoot = path.resolve(__dirname, '../../');
|
|
4
|
+
|
|
5
|
+
module.exports = async function add(name) {
|
|
6
|
+
|
|
7
|
+
const themeRoot = process.cwd();
|
|
8
|
+
try {
|
|
9
|
+
const registry = await fs.readJson(path.join(libRoot, 'registry.json'));
|
|
10
|
+
const component = registry[name];
|
|
11
|
+
if(!component) throw new Error(`Component ${name} not found.`);
|
|
12
|
+
console.log(`Installing ${name}...`);
|
|
13
|
+
for(const file of component.files) {
|
|
14
|
+
const src = path.join(libRoot, file.src);
|
|
15
|
+
const dest = path.join(themeRoot, file.destDir, `lib-${path.basename(file.src)}`);
|
|
16
|
+
await fs.ensureDir(path.dirname(dest));
|
|
17
|
+
await fs.copy(src, dest);
|
|
18
|
+
}
|
|
19
|
+
console.log(`Successfully added ${name} to your theme.`);
|
|
20
|
+
} catch (err) {
|
|
21
|
+
console.error(err.message);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
};
|