Skip to content

Commit

Permalink
- add init command ( npx fedep init ) for quickly setup a
Browse files Browse the repository at this point in the history
   `frontendDependencies` entry.
  • Loading branch information
zbryikt committed Oct 23, 2021
1 parent 09112ce commit 61f105e
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Logs

## v0.0.17

- add `init` command ( `npx fedep init` ) for quickly setup a `frontendDependencies` entry.


## v0.0.16

- support `link` option for linking from src to des.
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ Once configuration is prepared, run:
npx fedep


You can also use local repo for a specific module:
for a quick setup of `frontendDependencies` field, run:

npx fedep init

you still have to update its fields according to what you need.


Additionally, you can also use local repo for a specific module:

npx fedep -l <some-module>:<path-to-local-repo>

Expand Down
29 changes: 28 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
var fs, path, os, fsExtra, browserify, yargs, argv, ret, localModule, useSymlink, fed, slice$ = [].slice;
var fs, path, os, fsExtra, browserify, yargs, argv, ret, localModule, cmd, json, k, useSymlink, fed, slice$ = [].slice;
fs = require('fs');
path = require('path');
os = require('os');
Expand All @@ -25,6 +25,33 @@ if (argv.l) {
} else {
localModule = null;
}
cmd = argv._[0];
if (cmd === 'init') {
json = JSON.parse(fs.readFileSync('package.json').toString());
if (json.frontendDependencies) {
console.log("package.json has already inited. skipped. ");
} else {
json.frontendDependencies = {
root: "web/static/assets/lib",
modules: Array.from(new Set((function(){
var results$ = [];
for (k in json.dependencies) {
results$.push(k);
}
return results$;
}()).concat((function(){
var results$ = [];
for (k in json.devDependencies) {
results$.push(k);
}
return results$;
}()))))
};
fs.writeFileSync("package.json", JSON.stringify(json, null, ' '));
console.log("package.json updated.");
}
process.exit();
}
useSymlink = argv.s != null ? argv.s : true;
fed = import$({
root: '.',
Expand Down
16 changes: 15 additions & 1 deletion lib/main.ls
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,23 @@ argv = yargs
if argv.l =>
ret = argv.l.split(\:)
local-module = name: ret.0, path: path.resolve(ret.1.replace(/^~/, os.homedir!))

else local-module = null

cmd = argv._.0

if cmd == \init =>
json = JSON.parse(fs.read-file-sync 'package.json' .toString!)
if json.frontendDependencies =>
console.log "package.json has already inited. skipped. "
else
json.frontendDependencies = {
root: "web/static/assets/lib"
modules: Array.from(new Set([k for k of json.dependencies] ++ [k for k of json.devDependencies]))
}
fs.write-file-sync "package.json", JSON.stringify(json, null, ' ')
console.log "package.json updated."
process.exit!

use-symlink = if argv.s? => argv.s else true

fed = {root: '.', modules: []} <<< (JSON.parse(fs.read-file-sync "package.json" .toString!).frontendDependencies or {})
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"cli.js"
],
"description": "Frontend dependency installer",
"version": "0.0.16",
"version": "0.0.17",
"homepage": "https://github.com/plotdb/fedep",
"repository": {
"type": "git",
Expand Down

0 comments on commit 61f105e

Please sign in to comment.