Skip to content

Commit 915c7f1

Browse files
committed
pushing for Eric
1 parent c6f4d45 commit 915c7f1

File tree

3 files changed

+39
-7
lines changed

3 files changed

+39
-7
lines changed

src/commands/plugins/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default class PluginsIndex extends Command {
2828
})
2929

3030
let plugins = this.config.getPluginsList()
31+
console.log(`config returned this many ${plugins.length} and they were ${plugins.map(p => p.name).join(', ')}`)
3132
sortBy(plugins, (p) => this.plugins.friendlyName(p.name))
3233
if (!flags.core) {
3334
plugins = plugins.filter((p) => p.type !== 'core' && p.type !== 'dev')

src/plugins.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,14 @@ export default class Plugins {
164164
const {dependencies} = await this.pjson()
165165
const {default: npa} = await import('npm-package-arg')
166166
const normalizedUrl = npa(url)
167+
console.log(`=======`)
168+
169+
console.log(`target is ${JSON.stringify(normalizedUrl)}`)
170+
171+
167172
const matches = Object.entries(dependencies ?? {}).find(([, npmVersion]) => {
168173
const normalized = npa(npmVersion)
174+
console.log(`comparing to ${npmVersion}, ${JSON.stringify(normalized)}`)
169175
if (normalized.type !== normalizedUrl.type) {
170176
return false
171177
}
@@ -182,6 +188,7 @@ export default class Plugins {
182188
normalized.hosted?.project === normalizedUrl.hosted?.project
183189
)
184190
})
191+
console.log(`=======`)
185192

186193
const installedPluginName = matches?.[0]
187194
if (!installedPluginName) throw new Errors.CLIError(`Could not find plugin name for ${url}`)
@@ -217,14 +224,12 @@ export default class Plugins {
217224
}
218225
} else {
219226
// npm
220-
console.log(`L219`)
221227
const range = validRange(tag)
222228
const unfriendly = this.unfriendlyName(name)
223229
if (unfriendly && (await this.npmHasPackage(unfriendly))) {
224230
name = unfriendly
225231
}
226232

227-
console.log(`L226`)
228233
// validate that the package name exists in the npm registry before installing
229234
await this.npmHasPackage(name, true)
230235

@@ -237,17 +242,13 @@ export default class Plugins {
237242
root: join(this.config.dataDir, 'node_modules', name),
238243
userPlugins: false,
239244
})
240-
console.log(`L239`)
241245
this.debug(`finished loading plugin ${name} at root ${plugin.root}`)
242246
notifyUser(plugin, output)
243247
this.isValidPlugin(plugin)
244-
console.log(`L243`)
245248
await this.add({name, tag: range ?? tag, type: 'user'})
246249
}
247250

248-
console.log(`L246`)
249251
await rm(join(this.config.dataDir, 'yarn.lock'), {force: true})
250-
console.log(`L248`)
251252
console.log(`ending psjon ${JSON.stringify(await this.pjson(), null, 2)}`)
252253
return plugin
253254
} catch (error: unknown) {

test/integration/install.integration.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,13 @@ describe('install/uninstall integration tests', () => {
159159
const {result, stdout} = await runCommand<Array<{name: string}>>('plugins')
160160
expect(stdout).to.contain(pluginShortName)
161161
expect(result?.some((r) => r.name === plugin)).to.be.true
162+
await runCommand(`plugins install ${otherPlugin}`)
163+
const {stdout: otherStdout} = await runCommand<Array<{name: string}>>('plugins')
164+
expect(otherStdout).to.contain(otherPlugin)
162165
})
163166

164167
it('should uninstall plugin from github', async () => {
168+
await runCommand(`plugins uninstall ${otherPlugin}`)
165169
await runCommand(`plugins uninstall ${plugin}`)
166170
const {result, stdout} = await runCommand<Array<{name: string}>>('plugins')
167171
expect(stdout).to.contain('No plugins installed.')
@@ -185,7 +189,7 @@ describe('install/uninstall integration tests', () => {
185189
})
186190
})
187191

188-
describe('multiple plugins sequentially', async () => {
192+
describe('multiple plugins sequentially', () => {
189193
/**
190194
* This is a test for @W-21915680@, a bizarre bug wherein if you installed a plugin from the registry by its true name,
191195
* and then installed a local tarball whose package name is alphabetically after the previous one, the local tarball
@@ -212,6 +216,7 @@ describe('install/uninstall integration tests', () => {
212216
console.log(`third add stdout: ${thirdAdd}`)
213217
const {result: thirdResult, stdout: thirdStdout} = await runCommand<Array<{name: string}>>('plugins')
214218
expect(thirdStdout).to.contain(pluginShortName)
219+
console.log(`plugins stdout is ${thirdStdout}`)
215220
expect(thirdResult?.some((r) => r.name === otherPlugin)).to.be.true
216221
expect(thirdResult?.some((r) => r.name === yetAnotherPlugin)).to.be.true
217222
expect(thirdResult?.some((r) => r.name === plugin)).to.be.true
@@ -261,6 +266,7 @@ describe('install/uninstall integration tests', () => {
261266

262267
describe('legacy plugin', () => {
263268
it('should install legacy plugin', async () => {
269+
/*
264270
const {stdout: firstAdd} = await runCommand('plugins install @oclif/plugin-legacy')
265271
const {stdout: secondAdd} = await runCommand('plugins install @heroku-cli/plugin-ps-exec --silent')
266272
console.log(`firstStdout: ${firstAdd}`)
@@ -269,6 +275,30 @@ describe('install/uninstall integration tests', () => {
269275
console.log(`stdout is ${stdout}`)
270276
expect(stdout).to.contain('@heroku-cli/plugin-ps-exec')
271277
expect(result?.some((r) => r.name === '@heroku-cli/plugin-ps-exec')).to.be.true
278+
279+
*/
280+
const {stdout: otherAdd} = await runCommand('plugins install @oclif/plugin-version')
281+
console.log(`===== stdout from adding @oclif/plugin-version===\n${otherAdd}\n====`)
282+
283+
284+
const {stdout: otherPlugins} = await runCommand<Array<{ name: string}>>('plugins')
285+
console.log(`====== stdout from plugins call after that======\n${otherPlugins}\n======`)
286+
287+
288+
289+
const {stdout: firstAdd} = await runCommand('plugins install @oclif/plugin-legacy')
290+
const {result: firstResult, stdout: firstPlugins} = await runCommand<Array<{ name: string }>>('plugins')
291+
console.log(`===== stdout from adding @oclif/plugin-legacy =====\n${firstAdd}\n=======`)
292+
console.log(`=== stdout from running plugins command the first time ===\n${firstPlugins}\n====`)
293+
expect(firstPlugins).to.contain('@oclif/plugin-legacy')
294+
expect(firstResult?.some((r) => r.name === '@oclif/plugin-legacy')).to.be.true
295+
296+
const {stdout: secondAdd} = await runCommand('plugins install @heroku-cli/plugin-ps-exec --silent')
297+
console.log(`====== stdout from adding @heroku-cli/plugins-ps-exec --silent =====\n${secondAdd}\n==========`)
298+
const {result, stdout} = await runCommand<Array<{ name: string }>>('plugins')
299+
console.log(`====== stdout from running plugins command the second time ====\n${stdout}\n=====`)
300+
expect(stdout).to.contain('@heroku-cli/plugin-ps-exec')
301+
expect(result?.some((r) => r.name === '@heroku-cli/plugin-ps-exec')).to.be.true
272302
})
273303
})
274304
})

0 commit comments

Comments
 (0)