Skip to content

Commit

Permalink
refactor: change method of installing extensions (#4315)
Browse files Browse the repository at this point in the history
* update default extensions directory

* load builtin and remote extensions the same way

* refactor installing remote extensions

* update default extension manifest location

* refactor removing an extension

* add tests for npm

* add search method to npm module

* improve error logging

* add tests for downloading extension

* refactor manager tests

* deprecate extendsComposer

* add test for loadFromDir

* add more manager tests

* use npm registry api to search

* omit installed extensions from search

* add getBundle test

* remove rimraf, use remove from fs-extra

* make remvoing builtin a no-op

* add rimraf back to dev deps

* fix security warning by resolving to terser-webpack-plugin version

* ensure extensions cannot be installed outside remoteDir

* supress lgtm error
  • Loading branch information
a-b-r-o-w-n authored Oct 2, 2020
1 parent 2011ccd commit 00ba03a
Show file tree
Hide file tree
Showing 26 changed files with 726 additions and 429 deletions.
1 change: 1 addition & 0 deletions Composer/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ module.exports = {
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-object-literal-type-assertion': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-explicit-any': 'off',

'security/detect-buffer-noassert': 'off',
'security/detect-child-process': 'off',
Expand Down
3 changes: 2 additions & 1 deletion Composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"mkdirp": "^0.5.2",
"selfsigned": "1.10.8",
"serialize-javascript": "^3.1.0",
"set-value": "^3.0.2"
"set-value": "^3.0.2",
"terser-webpack-plugin": "^2.3.7"
},
"engines": {
"node": ">=12"
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/electron-server/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async function createAppDataDir() {
const azurePublishPath: string = join(composerAppDataPath, 'publishBots');
process.env.COMPOSER_APP_DATA = join(composerAppDataPath, 'data.json'); // path to the actual data file
process.env.COMPOSER_EXTENSION_DATA = join(composerAppDataPath, 'extensions.json');
process.env.COMPOSER_REMOTE_EXTENSIONS_DIR = join(composerAppDataPath, '.composer');
process.env.COMPOSER_REMOTE_EXTENSIONS_DIR = join(composerAppDataPath, 'extensions');

log('creating composer app data path at: ', composerAppDataPath);

Expand Down
7 changes: 5 additions & 2 deletions Composer/packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"build": "yarn build:clean && yarn build:ts",
"build:ts": "tsc -p tsconfig.build.json",
"build:clean": "rimraf lib && rimraf build",
"build:clean": "rimraf lib",
"lint": "eslint --quiet ./src",
"test": "jest"
},
Expand All @@ -18,6 +18,7 @@
"@types/fs-extra": "^9.0.1",
"@types/passport": "^1.0.3",
"@types/path-to-regexp": "^1.7.0",
"@types/tar": "^4.0.3",
"json-schema": "^0.2.5",
"rimraf": "^3.0.2",
"typescript": "^3.8.3"
Expand All @@ -26,7 +27,9 @@
"debug": "^4.1.1",
"fs-extra": "^9.0.1",
"globby": "^11.0.0",
"node-fetch": "^2.6.1",
"passport": "^0.4.1",
"path-to-regexp": "^6.1.0"
"path-to-regexp": "^6.1.0",
"tar": "^6.0.5"
}
}
2 changes: 1 addition & 1 deletion Composer/packages/extension/src/extensionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class ExtensionContext {
const packageJSON = fs.readFileSync(packageJsonPath, 'utf8');
const json = JSON.parse(packageJSON);

if (json.extendsComposer) {
if (json.composer?.enabled !== false) {
const modulePath = path.dirname(packageJsonPath);
try {
// eslint-disable-next-line security/detect-non-literal-require, @typescript-eslint/no-var-requires
Expand Down
Loading

0 comments on commit 00ba03a

Please sign in to comment.