-
-
Notifications
You must be signed in to change notification settings - Fork 55
[feature]: allow to install node modules from GitHub url too #2797
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
Changes from all commits
bdd3c23
81c0619
eb57e5d
86bff1c
acbc1d7
e70d216
6590f76
cd31607
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,8 @@ | |
getSupportedFeatures, | ||
isMessageboxSupported, | ||
getAdapterScopedPackageIdentifier, | ||
listInstalledNodeModules | ||
listInstalledNodeModules, | ||
requestModuleNameByUrl | ||
} from '@/lib/adapter/utils.js'; | ||
// @ts-expect-error no ts file | ||
import extend from 'node.extend'; | ||
|
@@ -1249,21 +1250,30 @@ | |
/** | ||
* Install specified npm module | ||
* | ||
* @param moduleName name of the node module | ||
* @param moduleNameOrUrl name of the node module or GitHub url which can be passed to `npm install` | ||
* @param options version information | ||
*/ | ||
installNodeModule(moduleName: unknown, options: unknown): Promise<CommandResult> { | ||
Validator.assertString(moduleName, 'moduleName'); | ||
installNodeModule(moduleNameOrUrl: unknown, options: unknown): Promise<CommandResult> { | ||
Validator.assertString(moduleNameOrUrl, 'moduleNameOrUrl'); | ||
Validator.assertObject<InstallNodeModuleOptions>(options, 'options'); | ||
|
||
return this._installNodeModule({ ...options, moduleName }); | ||
return this._installNodeModule({ ...options, moduleNameOrUrl }); | ||
} | ||
|
||
private _installNodeModule(options: InternalInstallNodeModuleOptions): Promise<CommandResult> { | ||
const { moduleName, version } = options; | ||
private async _installNodeModule(options: InternalInstallNodeModuleOptions): Promise<CommandResult> { | ||
const { moduleNameOrUrl, version } = options; | ||
|
||
let moduleName = moduleNameOrUrl; | ||
const isUrl = URL.canParse(moduleNameOrUrl); | ||
|
||
if (isUrl) { | ||
moduleName = await requestModuleNameByUrl(moduleNameOrUrl); | ||
} | ||
|
||
const internalModuleName = getAdapterScopedPackageIdentifier({ moduleName, namespace: this.namespace }); | ||
return tools.installNodeModule(`${internalModuleName}@npm:${moduleName}@${version}`); | ||
const packageIdentifier = isUrl ? moduleNameOrUrl : `npm:${moduleName}@${version}`; | ||
|
||
return tools.installNodeModule(`${internalModuleName}@${packageIdentifier}`); | ||
} | ||
|
||
/** | ||
|
@@ -1310,7 +1320,7 @@ | |
* Decrypt the password/value with given key | ||
* | ||
* @param secretVal to use for decrypt (or value if only one parameter is given) | ||
* @param [value] value to decrypt (if secret is provided) | ||
* @param value value to decrypt (if secret is provided) | ||
*/ | ||
decrypt(secretVal: unknown, value?: unknown): string { | ||
if (value === undefined) { | ||
|
@@ -1585,7 +1595,7 @@ | |
* ... | ||
* } | ||
* ``` | ||
|
||
* @param featureName the name of the feature to check | ||
* @returns true/false if the feature is in the list of supported features | ||
*/ | ||
|
@@ -5120,11 +5130,11 @@ | |
): void; | ||
|
||
/** | ||
* @param deviceName | ||
Check warning on line 5133 in packages/adapter/src/lib/adapter/adapter.ts
|
||
* @param common | ||
Check warning on line 5134 in packages/adapter/src/lib/adapter/adapter.ts
|
||
* @param _native | ||
Check warning on line 5135 in packages/adapter/src/lib/adapter/adapter.ts
|
||
* @param options | ||
Check warning on line 5136 in packages/adapter/src/lib/adapter/adapter.ts
|
||
* @param callback | ||
Check warning on line 5137 in packages/adapter/src/lib/adapter/adapter.ts
|
||
* @deprecated use `this.extendObject` instead | ||
*/ | ||
createDevice(deviceName: unknown, common: unknown, _native?: unknown, options?: unknown, callback?: unknown): any { | ||
|
@@ -5215,10 +5225,10 @@ | |
/** | ||
* Name of channel must be in format "channel" | ||
* | ||
* @param parentDevice | ||
Check warning on line 5228 in packages/adapter/src/lib/adapter/adapter.ts
|
||
* @param channelName | ||
Check warning on line 5229 in packages/adapter/src/lib/adapter/adapter.ts
|
||
* @param roleOrCommon | ||
Check warning on line 5230 in packages/adapter/src/lib/adapter/adapter.ts
|
||
* @param _native | ||
Check warning on line 5231 in packages/adapter/src/lib/adapter/adapter.ts
|
||
* @param options | ||
* @param callback | ||
* @deprecated use `this.extendObject` instead | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any need to set a cwd?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, not using any locally installed stuff