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

feat(cli) [WIP] Add support for plugins #892

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 8 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"@oclif/plugin-autocomplete": "0.3.0",
"@oclif/plugin-help": "3.2.20",
"@oclif/plugin-not-found": "1.2.4",
"@oclif/plugin-plugins": "^5.4.14",
"@oclif/plugin-which": "^2.2.34",
"adm-zip": "0.5.10",
"archiver": "5.3.1",
"browserify": "17.0.0",
Expand Down Expand Up @@ -100,16 +102,20 @@
"plugins": [
"@oclif/plugin-help",
"@oclif/plugin-not-found",
"@oclif/plugin-autocomplete"
"@oclif/plugin-autocomplete",
"@oclif/plugin-which",
"@oclif/plugin-plugins"
],
"scope": "@zapier",
"hooks": {
"init": [
"./src/oclif/hooks/versionInfo",
"./src/oclif/hooks/deprecated",
"./src/oclif/hooks/updateNotifier",
"./src/oclif/hooks/checkValidNodeVersion",
"./src/oclif/hooks/renderMarkdownHelp",
"./src/oclif/hooks/getAppRegistrationFieldChoices"
"./src/oclif/hooks/getAppRegistrationFieldChoices",
"./src/oclif/hooks/registerPluginInterface"
]
},
"topics": {
Expand Down
5 changes: 5 additions & 0 deletions packages/cli/src/oclif/hooks/registerPluginInterface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { callAPI } = require('../../utils/api');

module.exports = async function () {
global.callAPI = async (options) => callAPI('', options);
};
27 changes: 14 additions & 13 deletions packages/cli/src/utils/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ const callAPI = async (
if (!options.skipDeployKey) {
const credentials = await readCredentials(credentialsRequired);
requestOptions.headers['X-Deploy-Key'] = credentials[constants.AUTH_KEY];
requestOptions.headers.Authorization = `JWT ${
credentials[constants.AUTH_KEY]
}`;
console.log(requestOptions.headers);
}

const res = await fetch(url, requestOptions);
Expand Down Expand Up @@ -162,22 +166,19 @@ const createCanary = async (versionFrom, versionTo, percent, duration) => {
method: 'POST',
body: {
percent,
duration
}
duration,
},
}
)
}
);
};

const listCanaries = async () => {
const linkedAppId = (await getLinkedAppConfig(undefined, true))?.id;

return callAPI(
`/apps/${linkedAppId}/canaries`,
{
method: 'GET',
}
)
}
return callAPI(`/apps/${linkedAppId}/canaries`, {
method: 'GET',
});
};

const deleteCanary = async (versionFrom, versionTo) => {
const linkedAppId = (await getLinkedAppConfig(undefined, true))?.id;
Expand All @@ -187,8 +188,8 @@ const deleteCanary = async (versionFrom, versionTo) => {
{
method: 'DELETE',
}
)
}
);
};

/**
* read local `apprc` file
Expand Down
Loading