Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge netlify-dev-plugin in CLI #396

Merged
merged 9 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,132 changes: 1,917 additions & 215 deletions package-lock.json

Large diffs are not rendered by default.

51 changes: 43 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,51 +60,86 @@
},
"dependencies": {
"@netlify/cli-utils": "^1.0.7",
"@oclif/command": "^1.5.14",
"@netlify/rules-proxy": "^0.1.4",
"@netlify/zip-it-and-ship-it": "^0.3.1",
"@oclif/command": "^1.5.18",
"@oclif/config": "^1.13.2",
"@oclif/errors": "^1.1.2",
"@oclif/plugin-help": "^2.2.0",
"@oclif/plugin-not-found": "^1.1.4",
"@oclif/plugin-plugins": "^1.7.8",
"@oclif/test": "^1.2.5",
"@octokit/rest": "^16.28.1",
"ansi-styles": "^3.2.1",
"ascii-table": "0.0.9",
"body-parser": "^1.19.0",
"boxen": "^4.1.0",
"chai": "^4.2.0",
"chalk": "^2.4.2",
"chokidar": "^3.0.2",
"ci-info": "^2.0.0",
"clean-deep": "^3.0.2",
"cli-spinners": "^1.3.1",
"cli-ux": "^5.2.1",
"concordance": "^4.0.0",
"copy-template-dir": "^1.4.0",
"debug": "^4.1.1",
"envinfo": "^7.3.1",
"eslint-config-oclif": "^3.1.0",
"execa": "^2.0.3",
"express": "^4.17.1",
"express-logging": "^1.1.1",
"find-up": "^3.0.0",
"fs-extra": "^8.1.0",
"fuzzy": "^0.1.3",
"get-port": "^5.0.0",
"gh-release-fetch": "^1.0.3",
"git-remote-origin-url": "^2.0.0",
"git-repo-info": "^2.1.0",
"inquirer": "^6.3.1",
"globby": "^10.0.1",
"http-proxy": "^1.17.0",
"husky": "^3.0.3",
"inquirer": "^6.5.1",
"inquirer-autocomplete-prompt": "^1.0.1",
"is-docker": "^1.1.0",
"jwt-decode": "^2.2.0",
"lint-staged": "^9.2.1",
"lodash.get": "^4.4.2",
"lodash.isempty": "^4.4.0",
"lodash.isequal": "^4.5.0",
"lodash.sample": "^4.2.1",
"log-symbols": "^2.2.0",
"mocha": "^6.2.0",
"netlify": "^2.4.8",
"netlify-cli-logo": "^1.0.0",
"netlify-dev-plugin": "^1.0.28",
"nock": "^10.0.6",
"node-fetch": "^2.6.0",
"npm-packlist": "^1.4.4",
"open": "^6.4.0",
"ora": "^3.4.0",
"p-wait-for": "^2.0.0",
"parse-github-url": "^1.0.2",
"parse-gitignore": "^1.0.1",
"precinct": "^6.1.2",
"prettyjson": "^1.2.1",
"random-item": "^1.0.0",
"update-notifier": "^2.5.0"
"read-pkg-up": "^6.0.0",
"require-package-name": "^2.0.1",
"resolve": "^1.12.0",
"safe-join": "^0.1.3",
"static-server": "^2.2.1",
"update-notifier": "^2.5.0",
"wait-port": "^0.2.2",
"wrap-ansi": "^6.0.0"
},
"devDependencies": {
"@oclif/dev-cli": "^1.22.0",
"auto-changelog": "^1.13.0",
"@oclif/dev-cli": "^1.22.2",
"auto-changelog": "^1.14.1",
"ava": "^1.4.1",
"body": "^5.1.0",
"coveralls": "^3.0.4",
"dependency-check": "^3.3.0",
"dependency-check": "^3.4.1",
"dependency-cruiser": "^4.22.0",
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.3.0",
Expand All @@ -115,9 +150,9 @@
"gh-release": "^3.5.0",
"markdown-magic": "^0.1.25",
"mkdirp": "^0.5.1",
"npm-run-all": "^4.1.3",
"npm-run-all": "^4.1.5",
"nyc": "^13.3.0",
"prettier": "^1.16.4",
"prettier": "^1.18.2",
"strip-ansi": "^5.2.0"
},
"ava": {
Expand Down
46 changes: 46 additions & 0 deletions src/commands/dev/exec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const execa = require("execa");
const Command = require("@netlify/cli-utils");
const { track } = require("@netlify/cli-utils/src/utils/telemetry");
const {
// NETLIFYDEV,
NETLIFYDEVLOG,
// NETLIFYDEVWARN,
NETLIFYDEVERR
} = require("netlify-cli-logo");

class ExecCommand extends Command {
async run() {
const { site, api } = this.netlify;
if (site.id) {
this.log(
`${NETLIFYDEVLOG} Checking your site's environment variables...`
); // just to show some visual response first
const accessToken = api.accessToken;
const { addEnvVariables } = require("../../utils/dev");
await addEnvVariables(api, site, accessToken);
} else {
this.log(
`${NETLIFYDEVERR} No Site ID detected. You probably forgot to run \`netlify link\` or \`netlify init\`. `
);
}
execa(this.argv[0], this.argv.slice(1), {
env: process.env,
stdio: "inherit"
});
// Todo hoist this telemetry `command` to CLI hook
track("command", {
command: "dev:exec"
});
}
}

ExecCommand.description = `Exec command
Runs a command within the netlify dev environment, e.g. with env variables from any installed addons
`;

ExecCommand.examples = ["$ netlify exec npm run bootstrap"];

ExecCommand.strict = false;
ExecCommand.parse = false;

module.exports = ExecCommand;
Loading