Skip to content

Commit

Permalink
feat(create-rediagram-project): display message when graphviz is not …
Browse files Browse the repository at this point in the history
…installed #106

fix #106
  • Loading branch information
kamiazya committed Nov 16, 2020
1 parent 74e5c6a commit 994deaf
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 12 deletions.
4 changes: 3 additions & 1 deletion packages/create-rediagram-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"fs-extra": "^9.0.1",
"ncp": "^2.0.0",
"replacestream": "^4.0.3",
"validate-npm-package-name": "^3.0.0"
"validate-npm-package-name": "^3.0.0",
"which": "^2.0.2"
},
"devDependencies": {
"@types/commander": "^2.12.2",
Expand All @@ -44,6 +45,7 @@
"@types/node": "^14.11.8",
"@types/replacestream": "^4.0.0",
"@types/validate-npm-package-name": "^3.0.0",
"@types/which": "^1.3.2",
"rimraf": "^3.0.2",
"rollup": "^2.32.0",
"rollup-plugin-typescript2": "^0.28.0",
Expand Down
1 change: 1 addition & 0 deletions packages/create-rediagram-project/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default {
'cross-spawn',
'dedent',
'validate-npm-package-name',
'which',
],
plugins: [typescript()],
};
45 changes: 34 additions & 11 deletions packages/create-rediagram-project/src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import fs from 'fs-extra';
import chalk from 'chalk';
import { ncp } from 'ncp';
import path from 'path';
import which from 'which';
import replacestream from 'replacestream';
import spawn from 'cross-spawn';
import dedent from 'dedent';
Expand Down Expand Up @@ -40,37 +41,59 @@ export const command = createCommand(pkg.name)
() => {
console.log(chalk`🌈 Creating new rediagram project in {bold ${name}}.`);
console.log();
console.log(chalk`⭐️ Installing packages. This take a couple of minutes.`);

if (which.sync('dot', { nothrow: true }) === null) {
console.log(
dedent(chalk`
👇 Install the dependent software:
- {bold Graphviz}
- {white.underline https://graphviz.org/download/}
`),
);
console.log();
}

console.log('⭐️ Installing packages. This take a couple of minutes.');
console.log();
console.log(chalk`Running {bold $} {cyan ${packageManager}} install`);
spawn.sync(packageManager, ['install'], {
cwd: dist,
stdio: 'inherit',
});
console.log();
console.log(`✨ The installation is complete.`);
console.log();

console.log(
dedent(chalk`
✨ The installation is complete.
👉 Get started with following commands:
{gray # Move to the project directory with the following command.}
{bold $} {cyan cd} ${name}
`),
);
console.log();

console.log(
dedent(chalk`
🚀 {bold In the project directory, you can run:}
{gray # Runs {bold src/*.rediagram.tsx} scripts and output the image with rediagram.}
{bold $} {cyan ${packageManager}} start
`),
);
console.log();

console.log(
chalk`
{yellow.bold Tahnks for installing rediagram 🙏}
Please consider donating to help
maintain rediagram packages!
{yellow.bold Tahnks for installing rediagram 🙏}
Please consider donating to help
maintain rediagram packages!
GitHub Sponsor: {white.underline https://github.com/sponsors/kamiazya/}
ko-fi: {white.underline https://ko-fi.com/kamiazya}
`),
GitHub Sponsor: {white.underline https://github.com/sponsors/kamiazya/}
ko-fi: {white.underline https://ko-fi.com/kamiazya}`,
);
console.log();
},
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3435,6 +3435,11 @@
"@types/webpack-sources" "*"
source-map "^0.6.0"

"@types/which@^1.3.2":
version "1.3.2"
resolved "https://registry.yarnpkg.com/@types/which/-/which-1.3.2.tgz#9c246fc0c93ded311c8512df2891fb41f6227fdf"
integrity sha512-8oDqyLC7eD4HM307boe2QWKyuzdzWBj56xI/imSl2cpL+U3tCMaTAkMJ4ee5JBZ/FsOJlvRGeIShiZDAl1qERA==

"@types/yargs-parser@*":
version "15.0.0"
resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-15.0.0.tgz#cb3f9f741869e20cce330ffbeb9271590483882d"
Expand Down

0 comments on commit 994deaf

Please sign in to comment.