deploy.sh 1.0.0 → 2.0.0

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.
Files changed (129) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc +4 -15
  3. package/.github/workflows/ci.yml +48 -0
  4. package/.husky/pre-commit +5 -0
  5. package/{test/fixtures/static/out.gifcd → .prettierrc} +0 -0
  6. package/.release-it.json +5 -0
  7. package/README.md +3 -4
  8. package/{test → __tests__}/fixtures/unknown/.gitkeep +0 -0
  9. package/__tests__/lib/classifier.test.js +49 -0
  10. package/__tests__/lib/helpers/util.test.js +57 -0
  11. package/bin/deploy-delete.js +5 -2
  12. package/bin/deploy-deploy.js +16 -11
  13. package/bin/deploy-list.js +17 -9
  14. package/bin/deploy-login.js +25 -21
  15. package/bin/deploy-logout.js +8 -4
  16. package/bin/deploy-logs.js +19 -12
  17. package/bin/deploy-open.js +13 -6
  18. package/bin/deploy-register.js +25 -20
  19. package/bin/deploy-server.js +9 -3
  20. package/bin/deploy-whoami.js +8 -6
  21. package/bin/deploy.js +97 -71
  22. package/{test/fixtures → examples}/docker/Dockerfile +0 -0
  23. package/examples/docker/index.js +12 -0
  24. package/examples/node/index.js +8 -0
  25. package/{test/fixtures → examples}/node/package.json +0 -0
  26. package/examples/static/index.html +22 -0
  27. package/{test/fixtures → examples}/static/main.css +4 -2
  28. package/examples/static/out.gifcd +0 -0
  29. package/generate-docs.js +55 -0
  30. package/index.js +37 -23
  31. package/lib/classifier.js +18 -16
  32. package/lib/deploy.js +30 -22
  33. package/lib/helpers/cli.js +66 -59
  34. package/lib/helpers/util.js +36 -30
  35. package/lib/models/deployment.js +157 -138
  36. package/lib/models/request.js +29 -26
  37. package/lib/models/user.js +41 -32
  38. package/lib/server.js +177 -131
  39. package/lib/static/static-server.js +52 -51
  40. package/package.json +43 -33
  41. package/website/README.md +41 -0
  42. package/website/babel.config.js +3 -0
  43. package/website/docs/api/_category_.yml +1 -0
  44. package/website/docs/api/lib/classifier.js.md +11 -0
  45. package/website/docs/api/lib/deploy.js.md +13 -0
  46. package/website/docs/api/lib/helpers/cli.js.md +193 -0
  47. package/website/docs/api/lib/helpers/util.js.md +65 -0
  48. package/website/docs/api/lib/models/deployment.js.md +171 -0
  49. package/website/docs/api/lib/models/request.js.md +67 -0
  50. package/website/docs/api/lib/models/user.js.md +92 -0
  51. package/website/docs/api/lib/server.js.md +0 -0
  52. package/website/docs/api/lib/static/static-server.js.md +0 -0
  53. package/website/docs/intro.md +57 -0
  54. package/website/docusaurus.config.js +82 -0
  55. package/website/package-lock.json +25218 -0
  56. package/website/package.json +39 -0
  57. package/website/sidebars.js +31 -0
  58. package/website/src/components/HomepageFeatures/index.js +79 -0
  59. package/website/src/components/HomepageFeatures/styles.module.css +11 -0
  60. package/website/src/css/custom.css +39 -0
  61. package/website/src/pages/index.js +57 -0
  62. package/website/src/pages/index.module.css +23 -0
  63. package/website/static/.nojekyll +0 -0
  64. package/{docs → website/static}/example.gif +0 -0
  65. package/{docs → website/static}/example.mov +0 -0
  66. package/website/static/img/favicon.ico +0 -0
  67. package/website/static/img/intro/deploy.png +0 -0
  68. package/website/static/img/intro/logs.png +0 -0
  69. package/{docs → website/static/img}/logo.png +0 -0
  70. package/{docs → website/static/img}/logo.pxm +0 -0
  71. package/{docs → website/static/img}/logo@2x.png +0 -0
  72. package/.travis.yml +0 -9
  73. package/.tryitout +0 -48
  74. package/docs/code/CLI.html +0 -2901
  75. package/docs/code/Deployment.html +0 -2469
  76. package/docs/code/Request.html +0 -906
  77. package/docs/code/User.html +0 -1219
  78. package/docs/code/classifier.js.html +0 -121
  79. package/docs/code/deploy.js.html +0 -122
  80. package/docs/code/fonts/OpenSans-Bold-webfont.eot +0 -0
  81. package/docs/code/fonts/OpenSans-Bold-webfont.svg +0 -1830
  82. package/docs/code/fonts/OpenSans-Bold-webfont.woff +0 -0
  83. package/docs/code/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  84. package/docs/code/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
  85. package/docs/code/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  86. package/docs/code/fonts/OpenSans-Italic-webfont.eot +0 -0
  87. package/docs/code/fonts/OpenSans-Italic-webfont.svg +0 -1830
  88. package/docs/code/fonts/OpenSans-Italic-webfont.woff +0 -0
  89. package/docs/code/fonts/OpenSans-Light-webfont.eot +0 -0
  90. package/docs/code/fonts/OpenSans-Light-webfont.svg +0 -1831
  91. package/docs/code/fonts/OpenSans-Light-webfont.woff +0 -0
  92. package/docs/code/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  93. package/docs/code/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
  94. package/docs/code/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  95. package/docs/code/fonts/OpenSans-Regular-webfont.eot +0 -0
  96. package/docs/code/fonts/OpenSans-Regular-webfont.svg +0 -1831
  97. package/docs/code/fonts/OpenSans-Regular-webfont.woff +0 -0
  98. package/docs/code/fonts/OpenSans-Semibold-webfont.eot +0 -0
  99. package/docs/code/fonts/OpenSans-Semibold-webfont.svg +0 -1830
  100. package/docs/code/fonts/OpenSans-Semibold-webfont.ttf +0 -0
  101. package/docs/code/fonts/OpenSans-Semibold-webfont.woff +0 -0
  102. package/docs/code/fonts/OpenSans-SemiboldItalic-webfont.eot +0 -0
  103. package/docs/code/fonts/OpenSans-SemiboldItalic-webfont.svg +0 -1830
  104. package/docs/code/fonts/OpenSans-SemiboldItalic-webfont.ttf +0 -0
  105. package/docs/code/fonts/OpenSans-SemiboldItalic-webfont.woff +0 -0
  106. package/docs/code/helpers_cli.js.html +0 -315
  107. package/docs/code/helpers_util.js.html +0 -194
  108. package/docs/code/index.html +0 -66
  109. package/docs/code/models_deployment.js.html +0 -515
  110. package/docs/code/models_request.js.html +0 -158
  111. package/docs/code/models_user.js.html +0 -198
  112. package/docs/code/module-lib_classifier.html +0 -246
  113. package/docs/code/module-lib_deploy.html +0 -350
  114. package/docs/code/module-lib_helpers_util.html +0 -707
  115. package/docs/code/scripts/linenumber.js +0 -25
  116. package/docs/code/scripts/prettify/Apache-License-2.0.txt +0 -202
  117. package/docs/code/scripts/prettify/lang-css.js +0 -2
  118. package/docs/code/scripts/prettify/prettify.js +0 -28
  119. package/docs/code/styles/jsdoc-default.css +0 -692
  120. package/docs/code/styles/prettify-jsdoc.css +0 -111
  121. package/docs/code/styles/prettify-tomorrow.css +0 -132
  122. package/docs/index.html +0 -4463
  123. package/docs/main.css +0 -162
  124. package/docs/main.js +0 -53
  125. package/test/fixtures/docker/index.js +0 -12
  126. package/test/fixtures/node/index.js +0 -8
  127. package/test/fixtures/static/index.html +0 -14
  128. package/test/lib/classifier.js +0 -51
  129. package/test/lib/helpers/util.js +0 -47
package/.eslintignore CHANGED
@@ -3,3 +3,4 @@ docs
3
3
  fixtures
4
4
  tmp
5
5
  coverage
6
+ website
package/.eslintrc CHANGED
@@ -1,23 +1,12 @@
1
1
  {
2
- "extends": "eslint:recommended",
2
+ "extends": ["eslint:recommended", "plugin:jest/recommended"],
3
+ "plugins": ["jest"],
3
4
  "env": {
4
5
  "es6": true,
5
6
  "node": true
6
7
  },
7
8
  "parserOptions": {
8
- "ecmaVersion": "2017"
9
- },
10
- "rules": {
11
- "no-inner-declarations": 0,
12
- "strict": 0,
13
- "semi": [
14
- "error",
15
- "always"
16
- ],
17
- "no-octal": 0,
18
- "indent": [
19
- "error",
20
- 2
21
- ]
9
+ "ecmaVersion": "latest",
10
+ "sourceType": "module"
22
11
  }
23
12
  }
@@ -0,0 +1,48 @@
1
+ name: Node.js CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ node-version: [16.x]
15
+ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ - name: Use Node.js ${{ matrix.node-version }}
19
+ uses: actions/setup-node@v2
20
+ with:
21
+ node-version: ${{ matrix.node-version }}
22
+ cache: "npm"
23
+ - run: npm i -g npm@7
24
+ - run: npm ci
25
+ - run: npm run build --if-present
26
+ - run: npm test
27
+
28
+ gh-release:
29
+ if: github.event_name != 'pull_request'
30
+ runs-on: ubuntu-latest
31
+ steps:
32
+ - uses: actions/checkout@v2
33
+ - uses: actions/setup-node@v2
34
+ with:
35
+ node-version: "16.x"
36
+ - uses: webfactory/ssh-agent@v0.5.3
37
+ with:
38
+ ssh-private-key: ${{ secrets.GH_PAGES_DEPLOY }}
39
+ - name: Release to GitHub Pages
40
+ env:
41
+ USE_SSH: true
42
+ GIT_USER: git
43
+ run: |
44
+ git config --global user.email "gabecsapo@gmail.com"
45
+ git config --global user.name "Gabriel J. Csapo"
46
+ cd website
47
+ npm install
48
+ npm run deploy
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ ./node_modules/.bin/eslint .
5
+ ./node_modules/.bin/pretty-quick --staged
File without changes
@@ -0,0 +1,5 @@
1
+ {
2
+ "github": {
3
+ "release": true
4
+ }
5
+ }
package/README.md CHANGED
@@ -1,15 +1,14 @@
1
- # deploy.sh <img align="right" src="docs/logo.png" width="120">
1
+ # deploy.sh <img align="right" src="website/static/img/logo.png" width="120">
2
2
 
3
3
  > ☁️ open source continuous deployment service
4
4
 
5
5
  [![Npm Version](https://img.shields.io/npm/v/deploy.sh.svg)](https://www.npmjs.com/package/deploy.sh)
6
- [![Coverage Status](https://lcov-server.gabrielcsapo.com/badge/github%2Ecom/gabrielcsapo/deploy.sh.svg)](https://lcov-server.gabrielcsapo.com/coverage/github%2Ecom/gabrielcsapo/deploy.sh)
7
6
  [![Dependency Status](https://starbuck.gabrielcsapo.com/badge/github/gabrielcsapo/deploy.sh/status.svg)](https://starbuck.gabrielcsapo.com/github/gabrielcsapo/deploy.sh)
8
7
  [![devDependency Status](https://starbuck.gabrielcsapo.com/badge/github/gabrielcsapo/deploy.sh/dev-status.svg)](https://starbuck.gabrielcsapo.com/github/gabrielcsapo/deploy.sh#info=devDependencies)
9
8
  [![Build Status](https://travis-ci.org/gabrielcsapo/deploy.sh.svg?branch=master)](https://travis-ci.org/gabrielcsapo/deploy.sh)
10
9
  ![npm](https://img.shields.io/npm/dt/deploy.sh.svg)
11
10
  ![npm](https://img.shields.io/npm/dm/deploy.sh.svg)
12
11
 
13
- ![Static Example](./docs/example.gif)
12
+ ![Static Example](./website/static/example.gif)
14
13
 
15
- To learn more visit [http://www.gabrielcsapo.com/deploy.sh/](http://www.gabrielcsapo.com/deploy.sh/)
14
+ To learn more visit [https://gabrielcsapo.github.io/deploy.sh](https://gabrielcsapo.github.io/deploy.sh)
File without changes
@@ -0,0 +1,49 @@
1
+ const path = require("path");
2
+
3
+ const classifier = require("../../lib/classifier");
4
+
5
+ describe("@lib/classifier", () => {
6
+ const baseDirectory = path.resolve(__dirname, "..", "..", "examples");
7
+
8
+ test("should be able to classify static site", async () => {
9
+ const directory = path.resolve(baseDirectory, "static");
10
+ const output = await classifier(directory);
11
+
12
+ expect(output).toEqual({
13
+ type: "static",
14
+ build: `\n FROM mhart/alpine-node:base-8\n WORKDIR ${directory}\n ADD . .\n\n CMD ["node", "index.js"]\n `,
15
+ });
16
+ });
17
+
18
+ test("should be able to classify node site", async () => {
19
+ const directory = path.resolve(baseDirectory, "node");
20
+ const output = await classifier(directory);
21
+
22
+ expect(output).toEqual({
23
+ type: "node",
24
+ build: `\n FROM mhart/alpine-node:8\n WORKDIR ${directory}\n ADD . .\n\n RUN npm install\n\n CMD ["npm", "start"]\n `,
25
+ });
26
+ });
27
+
28
+ test("should be able to classify docker site", async () => {
29
+ const directory = path.resolve(baseDirectory, "docker");
30
+ const output = await classifier(directory);
31
+
32
+ expect(output).toEqual({
33
+ type: "docker",
34
+ build: `FROM mhart/alpine-node:8\nWORKDIR ${directory}\nADD . .\n\nCMD ["node", "index.js"]\n`,
35
+ });
36
+ });
37
+
38
+ test("should be able to classify unknown deploy target", async () => {
39
+ const directory = path.resolve(
40
+ path.resolve(__dirname, "..", "fixtures"),
41
+ "unknown"
42
+ );
43
+ const output = await classifier(directory);
44
+
45
+ expect(output).toEqual({
46
+ type: "unknown",
47
+ });
48
+ });
49
+ });
@@ -0,0 +1,57 @@
1
+ const os = require("os");
2
+ const fs = require("fs");
3
+
4
+ const {
5
+ getPort,
6
+ hash,
7
+ contains,
8
+ mk,
9
+ rm,
10
+ } = require("../../../lib/helpers/util");
11
+
12
+ describe("@lib/util", () => {
13
+ test("@getPort: should be able return a valid port", async () => {
14
+ let port = await getPort();
15
+ let port1 = await getPort();
16
+
17
+ expect(Number.isInteger(port)).toBeTruthy();
18
+ expect(Number.isInteger(port1)).toBeTruthy();
19
+ expect(port !== port1).toBeTruthy();
20
+ });
21
+
22
+ test("@hash: should return a proper lowercase hash", () => {
23
+ const ret = hash(6);
24
+ expect(ret.length).toBeTruthy();
25
+ expect(ret.toLowerCase()).toBeTruthy();
26
+ });
27
+
28
+ test("@contains: should be able to return a proper conditional for truthy and false cases", () => {
29
+ expect(
30
+ contains(
31
+ ["index.html", "main.css"],
32
+ ["index.html", "!Dockerfile", "!package.json"]
33
+ )
34
+ ).toBeTruthy();
35
+ expect(
36
+ contains(
37
+ ["index.html", "main.css", "Dockerfile"],
38
+ ["index.html", "!Dockerfile", "!package.json"]
39
+ )
40
+ ).toBeFalsy();
41
+ expect(
42
+ contains([], ["index.html", "!Dockerfile", "!package.json"])
43
+ ).toBeFalsy();
44
+ });
45
+
46
+ test("@mk / @rm: should be able to make recursive directory", async () => {
47
+ let directory = `${os.tmpdir()}/hello/world/this/is/a/nested/directory`;
48
+
49
+ await mk(directory);
50
+
51
+ expect(fs.existsSync(directory)).toBeTruthy();
52
+
53
+ await rm(directory);
54
+
55
+ expect(!fs.existsSync(directory)).toBeTruthy();
56
+ });
57
+ });
@@ -1,6 +1,9 @@
1
1
  #!/usr/bin/env node
2
+ import ora from "ora";
3
+
4
+ export default async function (cli) {
5
+ const spinner = ora().start();
2
6
 
3
- module.exports = async function(cli, spinner) {
4
7
  spinner.text = `Deleting deployment ${cli.application}`;
5
8
 
6
9
  const { token, username } = await cli.getCredentials();
@@ -8,4 +11,4 @@ module.exports = async function(cli, spinner) {
8
11
  await cli.deleteDeployment({ token, username, name: cli.application });
9
12
 
10
13
  spinner.succeed(`Deployment deleted, ${cli.application} successfully`);
11
- };
14
+ }
@@ -1,31 +1,36 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const fs = require('fs');
4
- const path = require('path');
3
+ import fs from "fs";
4
+ import path from "path";
5
+ import ora from "ora";
5
6
 
6
- module.exports = async function(cli, spinner) {
7
- spinner.text = 'Creating application bundle';
7
+ export default async function (cli) {
8
+ const spinner = ora().start();
9
+
10
+ spinner.text = "Creating application bundle";
8
11
 
9
12
  await cli.createBundle(process.cwd());
10
13
 
11
- spinner.text = 'Getting deploy keys';
14
+ spinner.text = "Getting deploy keys";
12
15
 
13
16
  const { token, username } = await cli.getCredentials();
14
17
 
15
- spinner.text = 'Uploading application bundle';
18
+ spinner.text = "Uploading application bundle";
16
19
 
17
- const bundle = fs.createReadStream(path.resolve(process.cwd(), 'bundle.tgz'));
20
+ const bundle = fs.readFileSync(path.resolve(process.cwd(), "bundle.tgz"));
18
21
 
19
22
  const { deployment } = await cli.uploadBundle({
20
23
  name: path.basename(process.cwd()),
21
24
  bundle,
22
25
  token,
23
- username
26
+ username,
24
27
  });
25
28
 
26
- spinner.text = 'Cleaning up local files';
29
+ spinner.text = "Cleaning up local files";
27
30
 
28
31
  await cli.removeBundle(process.cwd());
29
32
 
30
- spinner.succeed(`Upload successfully, http://${deployment.subdomain}.localhost:5000`);
31
- };
33
+ spinner.succeed(
34
+ `Upload successfully, http://${deployment.subdomain}.localhost:5000`
35
+ );
36
+ }
@@ -1,18 +1,20 @@
1
1
  #!/usr/bin/env node
2
+ import moment from "moment";
3
+ import Url from "url";
4
+ import Table from "turtler";
5
+ import ora from "ora";
2
6
 
3
- const moment = require('moment');
4
- const Url = require('url');
5
- const Table = require('turtler');
7
+ export default async function (cli) {
8
+ const spinner = ora().start();
6
9
 
7
- module.exports = async function(cli, spinner) {
8
- spinner.text = 'Getting deployment list';
10
+ spinner.text = "Getting deployment list";
9
11
 
10
12
  const { token, username } = await cli.getCredentials();
11
13
  const { deployments } = await cli.getDeployments({ token, username });
12
14
 
13
15
  spinner.stop();
14
16
 
15
- if(deployments.length > 0) {
17
+ if (deployments.length > 0) {
16
18
  let data = [["name", "url", "age", "requests", "status"]];
17
19
 
18
20
  deployments.forEach((r, i) => {
@@ -20,13 +22,19 @@ module.exports = async function(cli, spinner) {
20
22
  config.host = `${r.subdomain}.${config.host}`;
21
23
  const url = Url.format(config);
22
24
 
23
- data[i + 1] = [r.name, url, moment(r.updated_at).fromNow(), r.requests.toString(), r.status];
25
+ data[i + 1] = [
26
+ r.name,
27
+ url,
28
+ moment(r.updated_at).fromNow(),
29
+ r.requests.toString(),
30
+ r.status,
31
+ ];
24
32
  });
25
33
 
26
34
  let table = new Table(data);
27
35
 
28
36
  console.log(table.markdown()); // eslint-disable-line
29
37
  } else {
30
- console.log('0 deployments found'); // eslint-disable-line
38
+ console.log("0 deployments found"); // eslint-disable-line
31
39
  }
32
- };
40
+ }
@@ -1,39 +1,43 @@
1
1
  #!/usr/bin/env node
2
+ import inquirer from "inquirer";
3
+ import ora from "ora";
2
4
 
3
- const inquirer = require('inquirer');
4
-
5
- module.exports = async function(cli, spinner) {
6
- spinner.stop();
5
+ export default async function (cli) {
6
+ const spinner = ora();
7
7
 
8
8
  const { username, password } = await inquirer.prompt([
9
9
  {
10
- name: 'username',
11
- type: 'input',
12
- message: 'Enter your e-mail address:',
13
- validate: function( value ) {
14
- if (value.length > 0 && value.indexOf('@') > -1 && value.indexOf('.') > -1) {
10
+ name: "username",
11
+ type: "input",
12
+ message: "Enter your e-mail address:",
13
+ validate: function (value) {
14
+ if (
15
+ value.length > 0 &&
16
+ value.indexOf("@") > -1 &&
17
+ value.indexOf(".") > -1
18
+ ) {
15
19
  return true;
16
20
  } else {
17
- return 'Please enter your e-mail address';
21
+ return "Please enter your e-mail address";
18
22
  }
19
- }
23
+ },
20
24
  },
21
25
  {
22
- name: 'password',
23
- type: 'password',
24
- message: 'Enter your password:',
26
+ name: "password",
27
+ type: "password",
28
+ message: "Enter your password:",
25
29
  mask: true,
26
- validate: function(value) {
30
+ validate: function (value) {
27
31
  if (value.length) {
28
32
  return true;
29
33
  } else {
30
- return 'Please enter your password';
34
+ return "Please enter your password";
31
35
  }
32
- }
33
- }
36
+ },
37
+ },
34
38
  ]);
35
- const credentials = await cli.login({ username, password});
39
+ const credentials = await cli.login({ username, password });
36
40
  await cli.cacheCredentials(credentials);
37
41
 
38
- console.log(`Successfully logged in as ${credentials.username}`); // eslint-disable-line
39
- };
42
+ spinner.succeed(`Logged in as ${credentials.username}`); // eslint-disable-line
43
+ }
@@ -1,12 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- module.exports = async function(cli, spinner) {
3
+ import ora from "ora";
4
+
5
+ export default async function (cli) {
6
+ const spinner = ora().start();
7
+
4
8
  const { token, username } = await cli.getCredentials();
5
9
 
6
10
  spinner.text = `Logging out of current session for ${username}`;
7
11
 
8
12
  await cli.logout({ token, username });
9
- await cli.cacheCredentials({ username: '', token: '' });
13
+ await cli.cacheCredentials({ username: "", token: "" });
10
14
 
11
- spinner.succeed(`Logged out of session for ${username} successfully`);
12
- };
15
+ spinner.succeed(`Logged out as ${username}`);
16
+ }
@@ -1,19 +1,26 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- module.exports = async function(cli, spinner) {
4
- spinner.text = `Getting logs for ${cli.application}`;
3
+ import ora from "ora";
5
4
 
6
- const { token, username } = await cli.getCredentials();
7
- const { logs } = await cli.getLogs({ token, username, name: cli.application });
5
+ export default async function (cli) {
6
+ const spinner = ora().start();
7
+
8
+ spinner.text = `Getting logs for application: "${cli.application}"`;
8
9
 
9
- spinner.stop();
10
+ const { token, username } = await cli.getCredentials();
11
+ const { logs } = await cli.getLogs({
12
+ token,
13
+ username,
14
+ name: cli.application,
15
+ });
10
16
 
11
- if(logs) {
12
- console.log('' + // eslint-disable-line
13
- `==========
14
- ${logs.join('').trim()}
15
- ==========`);
17
+ if (logs) {
18
+ spinner.info(`
19
+ ==========
20
+ ${logs.join("").trim()}
21
+ ==========
22
+ `);
16
23
  } else {
17
- console.log('No logs available 🙈'); // eslint-disable-line
24
+ spinner.info("No logs available 🙈"); // eslint-disable-line
18
25
  }
19
- };
26
+ }
@@ -1,13 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const Url = require('url');
4
- const opn = require('opn');
3
+ import Url from "url";
4
+ import opn from "opn";
5
+ import ora from "ora";
5
6
 
6
- module.exports = async function(cli, spinner) {
7
- spinner.text = 'Opening up url to deployment instance';
7
+ export default async function (cli) {
8
+ const spinner = ora().start();
9
+
10
+ spinner.text = "Opening up url to deployment instance";
8
11
 
9
12
  const { token, username } = await cli.getCredentials();
10
- const { deployment } = await cli.getDeployments({ token, username, name: cli.application });
13
+ const { deployment } = await cli.getDeployments({
14
+ token,
15
+ username,
16
+ name: cli.application,
17
+ });
11
18
 
12
19
  const config = Url.parse(cli.url);
13
20
  config.host = `${deployment.subdomain}.${config.host}`;
@@ -16,4 +23,4 @@ module.exports = async function(cli, spinner) {
16
23
  spinner.text = `Opening deployment at ${url}`;
17
24
  spinner.stopAndPersist();
18
25
  opn(url, { wait: false });
19
- };
26
+ }
@@ -1,40 +1,45 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const inquirer = require('inquirer');
3
+ import inquirer from "inquirer";
4
+ import ora from "ora";
5
+
6
+ export default async function (cli) {
7
+ const spinner = ora();
4
8
 
5
- module.exports = async function(cli, spinner) {
6
- spinner.stop();
7
-
8
9
  const { username, password } = await inquirer.prompt([
9
10
  {
10
- name: 'username',
11
- type: 'input',
12
- message: 'Enter a valid e-mail address:',
13
- validate: function( value ) {
14
- if (value.length > 0 && value.indexOf('@') > -1 && value.indexOf('.') > -1) {
11
+ name: "username",
12
+ type: "input",
13
+ message: "Enter a valid e-mail address:",
14
+ validate: function (value) {
15
+ if (
16
+ value.length > 0 &&
17
+ value.indexOf("@") > -1 &&
18
+ value.indexOf(".") > -1
19
+ ) {
15
20
  return true;
16
21
  } else {
17
- return 'Please enter a valid e-mail address';
22
+ return "Please enter a valid e-mail address";
18
23
  }
19
- }
24
+ },
20
25
  },
21
26
  {
22
- name: 'password',
23
- type: 'password',
24
- message: 'Enter a password:',
27
+ name: "password",
28
+ type: "password",
29
+ message: "Enter a password:",
25
30
  mask: true,
26
- validate: function(value) {
31
+ validate: function (value) {
27
32
  if (value.length) {
28
33
  return true;
29
34
  } else {
30
- return 'Please enter a password';
35
+ return "Please enter a password";
31
36
  }
32
- }
33
- }
37
+ },
38
+ },
34
39
  ]);
35
40
 
36
41
  const credentials = await cli.register({ username, password });
37
42
  await cli.cacheCredentials(credentials);
38
43
 
39
- console.log(`registered as ${credentials.username}`); // eslint-disable-line
40
- };
44
+ spinner.succeed(`registered as ${credentials.username}`); // eslint-disable-line
45
+ }
@@ -1,5 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- module.exports = async function(cli, spinner) {
4
- await require('../index.js')(cli, spinner);
5
- };
3
+ import ora from "ora";
4
+
5
+ export default async function (cli) {
6
+ const spinner = ora().start();
7
+
8
+ const { default: importCommand } = await import("../index.js");
9
+
10
+ importCommand(cli, spinner);
11
+ }
@@ -1,12 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- module.exports = async function(cli, spinner) {
4
- spinner.text = 'Figuring out who you are';
3
+ import ora from "ora";
4
+
5
+ export default async function (cli) {
6
+ const spinner = ora().start();
7
+
8
+ spinner.text = "Figuring out who you are";
5
9
 
6
10
  const { token, username } = await cli.getCredentials();
7
11
  const { user } = await cli.getUserDetails({ token, username });
8
12
 
9
- spinner.stop();
10
-
11
- console.log(`currently logged in as ${user.username}`); // eslint-disable-line
12
- };
13
+ spinner.info(`currently logged in as ${user.username}`); // eslint-disable-line
14
+ }