Skip to content

Commit

Permalink
Add support for plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
FokkeZB committed Oct 15, 2024
1 parent 9f159fb commit 5f34b6d
Show file tree
Hide file tree
Showing 4 changed files with 4,012 additions and 2,304 deletions.
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

0 comments on commit 5f34b6d

Please sign in to comment.