Skip to content

Commit

Permalink
fix: --ignore-scripts on github installs
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Nov 2, 2023
1 parent e10f2f7 commit b1a3cde
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"lint": "eslint . --ext .ts",
"postpublish": "yarn run clean",
"posttest": "yarn lint",
"prepare": "husky install",
"postinstall": "husky install",
"prepublishOnly": "yarn run build && oclif lock && oclif manifest . && oclif readme",
"pretest": "yarn build && tsc -p test --noEmit",
"preversion": "yarn run clean",
Expand Down
34 changes: 20 additions & 14 deletions src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,32 @@ export default class Plugins {
if (name.includes(':')) {
// url
const url = name
await this.yarn.exec([...add, url], yarnOpts)
await this.yarn.exec([...add, '--ignore-scripts', url], yarnOpts)
const {dependencies} = await this.pjson()
name = Object.entries(dependencies ?? {}).find(([, u]) => u === url)![0]
const root = join(this.config.dataDir, 'node_modules', name)
plugin = await Config.load({
devPlugins: false,
name,
root: join(this.config.dataDir, 'node_modules', name),
root,
userPlugins: false,
})
await this.refresh({all: true, prod: true}, plugin.root)
await this.refresh({all: true, prod: true})

this.isValidPlugin(plugin)

await this.add({name, type: 'user', url})

try {
// CJS plugins can be auto-transpiled at runtime but ESM plugins
// cannot. To support ESM plugins we need to compile them after
// installing them.
await this.yarn.exec(['run', 'tsc'], {...yarnOpts, cwd: plugin.root})
} catch (error) {
this.debug(error)
if (plugin.getPluginsList().find((p) => p.root === root)?.moduleType === 'module') {
try {
// CJS plugins can be auto-transpiled at runtime but ESM plugins
// cannot. To support ESM plugins we need to compile them after
// installing them.
await this.yarn.exec(['install'], {...yarnOpts, cwd: plugin.root})
await this.yarn.exec(['run', 'tsc'], {...yarnOpts, cwd: plugin.root})
} catch (error) {
this.debug(error)
}
}
} else {
// npm
Expand Down Expand Up @@ -221,10 +225,12 @@ export default class Plugins {

const pluginRoots = [...roots]
if (options.all) {
const userPluginsRoots = this.config
.getPluginsList()
.filter((p) => p.type === 'user')
.map((p) => p.root)
const plugins = await this.list()
const userPluginsRoots = plugins
.filter((p) => p.type === 'user' && !p.url)
.map((p) => this.config.plugins.get(p.name)?.root)
// eslint-disable-next-line unicorn/prefer-native-coercion-functions
.filter((r): r is string => Boolean(r))
pluginRoots.push(...userPluginsRoots)
}

Expand Down

0 comments on commit b1a3cde

Please sign in to comment.