Skip to content

Commit

Permalink
Feat/deploy cli update (#33)
Browse files Browse the repository at this point in the history
* progress

* fixing build errors with dependency upgrade

* removing failed edit

* Resolved failed tenant.yml deploy issue

* updating test runner for latest version of glob

* updated changelog for v1.4.0 release

* pinned version of winston to the one used by deploy cli
  • Loading branch information
Bobby Johnson authored Mar 28, 2023
1 parent cbe6e46 commit 07762d5
Show file tree
Hide file tree
Showing 8 changed files with 1,168 additions and 661 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"semi": "off"
},
"ignorePatterns": [
"out",
"dist",
"**/*.d.ts"
]
}
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,14 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
## [1.3.9] - 2023-03-02

### Removed
- Reverted deploy cli back to previous version
- Reverted deploy cli back to previous version

## [1.4.0] - 2023-03-28

### Changed
- updated dependencies
- updated auth0 deploy cli to 7.17.0
- updated tenant export and import code to latest version
- removed dependency on js-yaml delpoy cli handles directly
- updated required vscode version to 1.76.2
- updated test runner to use vscode version 1.76.2
1,720 changes: 1,093 additions & 627 deletions package-lock.json

Large diffs are not rendered by default.

44 changes: 23 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-labs",
"preview": true,
"displayName": "Auth0 Labs",
"version": "1.3.9",
"version": "1.4.0",
"description": "A Visual Studio Code extension for training lab automation and quick access to tenant information.",
"main": "./dist/extension.js",
"publisher": "auth0",
Expand All @@ -24,7 +24,7 @@
"url": "https://github.com/auth0-training/labs-vscode-extension/issues"
},
"engines": {
"vscode": "^1.75.1"
"vscode": "^1.76.2"
},
"galleryBanner": {
"color": "#373436",
Expand Down Expand Up @@ -53,45 +53,47 @@
"Other"
],
"devDependencies": {
"@types/auth0": "2.35.9",
"@types/auth0": "3.3.0",
"@types/chai": "4.3.4",
"@types/glob": "8.0.1",
"@types/js-yaml": "4.0.5",
"@types/glob": "8.1.0",
"@types/mocha": "10.0.1",
"@types/node": "18.13.0",
"@types/sinon": "10.0.13",
"@types/vscode": "1.75.1",
"@typescript-eslint/eslint-plugin": "5.52.0",
"@typescript-eslint/parser": "5.52.0",
"@types/vscode": "1.76.0",
"@typescript-eslint/eslint-plugin": "5.57.0",
"@typescript-eslint/parser": "5.57.0",
"@vscode/vsce": "^2.18.0",
"chai": "4.3.7",
"copy-webpack-plugin": "11.0.0",
"eslint": "8.34.0",
"eslint-config-prettier": "8.6.0",
"eslint": "8.36.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-prettier": "4.2.1",
"express": "4.18.2",
"glob": "8.1.0",
"mocha": "10.2.0",
"prettier": "2.8.4",
"sinon": "15.0.1",
"prettier": "2.8.7",
"sinon": "15.0.3",
"string-replace-loader": "3.1.0",
"superagent": "8.0.9",
"superagent-proxy": "3.0.0",
"supports-color": "9.3.1",
"ts-loader": "9.4.2",
"typescript": "4.9.5",
"vsce": "2.15.0",
"typescript": "5.0.2",
"vscode-test": "1.6.1",
"webpack": "5.75.0",
"webpack": "5.76.3",
"webpack-cli": "5.0.1"
},
"dependencies": {
"auth0": "3.2.0",
"auth0-deploy-cli": "7.3.7",
"axios": "1.3.3",
"js-yaml": "4.1.0",
"auth0": "3.3.0",
"auth0-deploy-cli": "7.17.0",
"axios": "1.3.4",
"openid-client": "5.4.0",
"qs": "6.11.0",
"ts-is-present": "1.2.2"
"qs": "6.11.1",
"ts-is-present": "1.2.2",
"winston": "3.8.2"
},
"overrides": {
"winston": "3.8.2"
},
"prettier": {
"printWidth": 80,
Expand Down
41 changes: 34 additions & 7 deletions src/features/deploy/commands.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable @typescript-eslint/naming-convention */
import * as vscode from 'vscode';
import * as path from 'path';
import { load } from 'js-yaml';
import { tools, dump } from 'auth0-deploy-cli';
import { dump, deploy } from 'auth0-deploy-cli/';
import { getClient } from '../../client';
import { getDomainFromToken } from '../../utils';
import { getDomainFromToken, getFileUri, readUriContents } from '../../utils';
import { ImportParams } from 'auth0-deploy-cli/lib/args';

const registerCommand = vscode.commands.registerCommand;

Expand Down Expand Up @@ -37,10 +37,10 @@ export class DeployCommands {
await dump({
output_folder: outputFolder,
format: 'yaml',
config: {
config: await this.mergeConfig(outputFolder, {
AUTH0_DOMAIN: getDomainFromToken(accessToken),
AUTH0_ACCESS_TOKEN: accessToken,
},
}),
});

vscode.window.showInformationMessage(
Expand All @@ -56,15 +56,24 @@ export class DeployCommands {
silentDeploy = async (e: vscode.Uri) => {
console.log('auth0.silentDeploy');
const filePath = e.path;
const fileDir = path.dirname(filePath);
const client = await getClient();
const accessToken = await client.getAccessToken();

if (!filePath || !accessToken) {
return;
}
try {
const assets = load(tools.loadFile(filePath, process.env));
await tools.deploy(assets, client, () => null);
const opts: ImportParams = {
input_file: filePath,
config: await this.mergeConfig(fileDir, {
AUTH0_ACCESS_TOKEN: accessToken,
AUTH0_DOMAIN: getDomainFromToken(accessToken),
AUTH0_CLIENT_ID: 'NEEDED FOR v7.17.0 Deploy CLI',
AUTH0_ALLOW_DELETE: false,
}),
};
await deploy(opts);
} catch (e: any) {
vscode.window.showErrorMessage(e.message);
}
Expand Down Expand Up @@ -93,4 +102,22 @@ export class DeployCommands {
`Successfully deployed ${path.basename(filePath)}`
);
};

mergeConfig = async (
outputFolder: string,
defaultConfig: any
): Promise<any> => {
console.log('auth0.mergeConfig');

return defaultConfig;

try {
const uri = getFileUri(`${outputFolder}/config.json`);
const data = await readUriContents(uri);
const localConfig = JSON.parse(data);
return { ...defaultConfig, ...localConfig };
} catch (e: any) {
return defaultConfig;
}
};
}
2 changes: 1 addition & 1 deletion tests/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function main() {
// The path to test runner
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './suite/index.js');
const vscodeExecutablePath = await downloadAndUnzipVSCode('1.75.1');
const vscodeExecutablePath = await downloadAndUnzipVSCode('1.76.2');
const cliPath =
resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath);

Expand Down
4 changes: 2 additions & 2 deletions tests/suite/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path';
import Mocha = require('mocha');
import { glob } from 'glob';
import * as Mocha from 'mocha';
import * as glob from 'glob';

export function run(): Promise<void> {
// Create the mocha test
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"target": "ES2020",
"outDir": "out",
"lib": [
"es2019"
"ES2020"
],
"sourceMap": true,
"strict": true /* enable all strict type-checking options */
Expand Down

0 comments on commit 07762d5

Please sign in to comment.