Skip to content

Commit

Permalink
feat: add dico fetch command
Browse files Browse the repository at this point in the history
  • Loading branch information
lihbr committed Jun 7, 2021
1 parent 8149c0f commit 0fcabd1
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 82 deletions.
165 changes: 83 additions & 82 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,84 +1,85 @@
{
"name": "@dico/cli",
"version": "0.0.6",
"description": "Dico.app Command Line Interface",
"keywords": [
"dico",
"cli",
"management"
],
"repository": {
"type": "git",
"url": "ssh://git@github.com/dico-app/dico-cli.git"
},
"license": "MIT",
"author": "Lucie Haberer <hello@lihbr.com> (https://lihbr.com)",
"bin": {
"dico": "bin/cli.js"
},
"files": [
"bin",
"postinstall.js"
],
"scripts": {
"build": "siroc build",
"dev": "siroc build --watch",
"release": "yarn build && yarn test && standard-version && git push --follow-tags && yarn build && npm publish",
"release:dry": "yarn build && yarn test && standard-version --dry-run",
"lint": "eslint --ext .js,.ts .",
"unit": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava",
"test": "yarn lint && yarn unit",
"postinstall": "node postinstall.js"
},
"husky": {
"hooks": {
"pre-commit": "yarn lint",
"commit-msg": "commitlint --env HUSKY_GIT_PARAMS"
}
},
"dependencies": {
"@lihbr/listr-update-renderer": "^0.5.1",
"cac": "^6.7.3",
"chalk": "^4.1.1",
"consola": "^2.15.3",
"detect-indent": "^6.1.0",
"exit": "^0.1.2",
"globby": "^11.0.3",
"inquirer": "^8.1.0",
"latest-version": "^5.1.0",
"listr": "^0.14.3",
"node-fetch": "^2.6.1",
"rc9": "^1.2.0",
"rxjs": "^7.1.0",
"semver": "^7.3.5"
},
"devDependencies": {
"@commitlint/cli": "12.1.4",
"@commitlint/config-conventional": "12.1.4",
"@types/exit": "0.1.31",
"@types/inquirer": "7.3.1",
"@types/listr": "0.14.3",
"@types/node-fetch": "2.5.10",
"@types/semver": "7.3.6",
"@typescript-eslint/eslint-plugin": "4.26.0",
"@typescript-eslint/parser": "4.26.0",
"ava": "3.15.0",
"eslint": "7.27.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-prettier": "3.4.0",
"husky": "4.3.8",
"nyc": "15.1.0",
"prettier": "2.3.0",
"siroc": "0.11.0",
"standard-version": "9.3.0",
"ts-eager": "2.0.2",
"ts-essentials": "7.0.1",
"typescript": "4.3.2"
},
"engines": {
"node": ">=12.0.0"
},
"publishConfig": {
"access": "public"
}
"name": "@dico/cli",
"version": "0.0.6",
"description": "Dico.app Command Line Interface",
"keywords": [
"dico",
"cli",
"management"
],
"repository": {
"type": "git",
"url": "ssh://git@github.com/dico-app/dico-cli.git"
},
"license": "MIT",
"author": "Lucie Haberer <hello@lihbr.com> (https://lihbr.com)",
"bin": {
"dico": "bin/cli.js"
},
"files": [
"bin",
"postinstall.js"
],
"scripts": {
"build": "siroc build",
"dev": "siroc build --watch",
"release": "yarn build && yarn test && standard-version && git push --follow-tags && yarn build && npm publish",
"release:dry": "yarn build && yarn test && standard-version --dry-run",
"lint": "eslint --ext .js,.ts .",
"unit": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava",
"test": "yarn lint && yarn unit",
"postinstall": "node postinstall.js"
},
"husky": {
"hooks": {
"pre-commit": "yarn lint",
"commit-msg": "commitlint --env HUSKY_GIT_PARAMS"
}
},
"dependencies": {
"@lihbr/listr-update-renderer": "^0.5.1",
"cac": "^6.7.3",
"chalk": "^4.1.1",
"consola": "^2.15.3",
"detect-indent": "^6.1.0",
"execa": "^5.1.1",
"exit": "^0.1.2",
"globby": "^11.0.3",
"inquirer": "^8.1.0",
"latest-version": "^5.1.0",
"listr": "^0.14.3",
"node-fetch": "^2.6.1",
"rc9": "^1.2.0",
"rxjs": "^7.1.0",
"semver": "^7.3.5"
},
"devDependencies": {
"@commitlint/cli": "12.1.4",
"@commitlint/config-conventional": "12.1.4",
"@types/exit": "0.1.31",
"@types/inquirer": "7.3.1",
"@types/listr": "0.14.3",
"@types/node-fetch": "2.5.10",
"@types/semver": "7.3.6",
"@typescript-eslint/eslint-plugin": "4.26.0",
"@typescript-eslint/parser": "4.26.0",
"ava": "3.15.0",
"eslint": "7.27.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-prettier": "3.4.0",
"husky": "4.3.8",
"nyc": "15.1.0",
"prettier": "2.3.0",
"siroc": "0.11.0",
"standard-version": "9.3.0",
"ts-eager": "2.0.2",
"ts-essentials": "7.0.1",
"typescript": "4.3.2"
},
"engines": {
"node": ">=12.0.0"
},
"publishConfig": {
"access": "public"
}
}
9 changes: 9 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ cli
await commands.push(cli, options);
});

cli
.command(
"fetch [base]",
"Fetch current dico from Dico.app using `@dico/client`"
)
.action(async options => {
await commands.fetch(cli, options);
});

cli.version(VERSION);
cli.help(commands.help);

Expand Down
19 changes: 19 additions & 0 deletions src/commands/fetch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { CAC } from "cac";
import execa from "execa";
import exit from "exit";
import { logger } from "../lib";
import * as messages from "../messages";

export const fetch = async (_: CAC, base = "./"): Promise<void> => {
try {
execa.sync("dico-fetch", [base], {
stdin: process.stdin,
stdout: process.stdout,
stderr: process.stderr
});
} catch (error) {
logger.fatal(error.message);
logger.info(messages.IsDicoClientInstalled);
exit(1);
}
};
1 change: 1 addition & 0 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export * from "./whoami";
export * from "./init";
export * from "./build";
export * from "./push";
export * from "./fetch";

export * from "./help";
export * from "./default";
3 changes: 3 additions & 0 deletions src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ export const CommandWithFlagCommand = `Running \`${NAME} %s\` with \`%s\` flag,
export const NowStartingCommand = `Now starting command \`${NAME} %s\`:`;

export const ProductionDicoNotInSync = `Production dico is not in sync with local \`${CONFIG_FILE}\``;

export const IsDicoClientInstalled =
"Are you sure `@dico/client` is installed in your project?";
15 changes: 15 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1984,6 +1984,21 @@ esutils@^2.0.2, esutils@^2.0.3:
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64"
integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==

execa@5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd"
integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==
dependencies:
cross-spawn "^7.0.3"
get-stream "^6.0.0"
human-signals "^2.1.0"
is-stream "^2.0.0"
merge-stream "^2.0.0"
npm-run-path "^4.0.1"
onetime "^5.1.2"
signal-exit "^3.0.3"
strip-final-newline "^2.0.0"

execa@^5.0.1:
version "5.1.0"
resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.0.tgz#3ea50ee863d226bfa323528cce1684e7481dfe46"
Expand Down

0 comments on commit 0fcabd1

Please sign in to comment.