-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [PFX-813] ESM: Port plugin-metadata (#978) * chore: convert to esm * tests: added vitest * chore: update changelog; remove jest deps * fix: test * chore: remove unused space * [PFX-793] Dynamic plugins (#970) * feat: dynamic plugins * chore: add cjs tranpilation * tests: default-plugins * tests: core * tests: dynamic index * tests: prepare hook * fix: lint * chore: add types for dynamic plugins * docs: dynamic plugins * chore: update package.json * docs: update changelog * chore: switch to utilize sub-environments * chore: add metadata * fix: lint * fix: test * chore: remove cjs transpilation * docs: update dynamic and core * fix: test * Update packages/gasket-plugin-dynamic-plugins/README.md Co-authored-by: Andrew Gerard <[email protected]> --------- Co-authored-by: Andrew Gerard <[email protected]> * chore: remove depreacted http2 dep (#981) * Normalized gasket request (#973) * feat: normalized gasket request * fix: attempt types adjustments * fix: types adjustments * test: the things * docs: package docs * fix: docs * fix: one way to make * fix: ensure expected defaults * fix: better types * fix: handle parallel executions * fix: next request helper * test: adjustments * fix: unused import * feat: add WeakPromiseKeeper for consistent promise to value caching * fix: types * fix: docs * feat: handle IncomingMessage url * fix: tighten types * fix: test cruft * docs: fix * fix: only parse url when needed * test: using gasket.symbol as weakmap key (#964) * Separate https-proxy plugin (#982) * feat: separate https-proxy plugin * feat: use https-proxy with prompts * fix: typos and grammar * fix: avoid default export * fix: return proxy server * chore: upgrade lerna * fix: publish issues for command plugin * docs: next.config.js (#987) * [PFX-507] Add DocSearch to Gasket Site (#984) * change dynamic require to string interpolation (#985) * pin react-intl version to 6.6.X (#988) * feat: initial fixup for getting command name early and using prepare lifecycle as an async config * Fix typo * Tune types * Opt for sync configure hook * Clean up old references to command.id * Add isReady, update command property * Update readme * Tune command plugin functionality * Add temp logging for debug * Cleanup debugs * Persist commands config when commandId is undefined * Tune tests * lockfile * remove duplicate tests from merge * lockfile * lockfile * feat: initial fixup for getting command name early and using prepare lifecycle as an async config * Fix typo * Tune types * Opt for sync configure hook * Clean up old references to command.id * Add isReady, update command property * Update readme * Tune command plugin functionality * Add temp logging for debug * Cleanup debugs * Persist commands config when commandId is undefined * Tune tests * Import plugin command types * Relax the regex for gasket file in argv * Remove timing from ready hook * fix test --------- Co-authored-by: Jordan Pina <[email protected]> Co-authored-by: Andrew Gerard <[email protected]> Co-authored-by: Andrew Gerard <[email protected]> Co-authored-by: Kawika Bader <[email protected]> Co-authored-by: bbetts-godaddy <[email protected]>
- Loading branch information
1 parent
b9641fc
commit b606b3d
Showing
23 changed files
with
196 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// @ts-nocheck | ||
/* eslint-disable no-unused-vars, no-sync */ | ||
import { applyConfigOverrides } from '@gasket/utils'; | ||
import { gasketBin, processCommand } from './cli.js'; | ||
const isGasketCommand = /gasket[.-\w]*\.(js|ts|cjs|mjs)$/; | ||
|
||
export default { | ||
timing: { | ||
first: true | ||
}, | ||
/** @type {import('@gasket/core').HookHandler<'configure'>} */ | ||
handler: function configure(gasket, config) { | ||
const hasGasket = process.argv.some(arg => isGasketCommand.test(arg)); | ||
|
||
if (hasGasket) { | ||
const cmds = gasket.execSync('commands'); | ||
const commandIds = cmds.reduce((acc, cmd) => { | ||
acc[cmd.id] = true; | ||
return acc; | ||
}, Object()); | ||
|
||
cmds.forEach(cmd => { | ||
const { command, hidden, isDefault } = processCommand(cmd); | ||
gasketBin.addCommand(command, { hidden, isDefault }); | ||
}); | ||
|
||
const commandId = [...process.argv].filter(arg => commandIds[arg])[0]; | ||
return { | ||
command: commandId, | ||
...applyConfigOverrides(config, { env: gasket.config.env, commandId }) | ||
}; | ||
} | ||
|
||
return config; | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,8 @@ | ||
/* eslint-disable no-unused-vars, no-sync */ | ||
import { gasketBin, processCommand } from './cli.js'; | ||
const isGasketCommand = /\/gasket\.(js|ts|cjs|mjs)$/; | ||
import { gasketBin } from './cli.js'; | ||
|
||
/** @type {import('@gasket/core').HookHandler<'ready'>} */ | ||
export default async function readyHook(gasket) { | ||
const hasGasket = process.argv.some(arg => isGasketCommand.test(arg)); | ||
|
||
if (hasGasket) { | ||
const cmds = await gasket.exec('commands'); | ||
cmds.forEach(cmd => { | ||
const { command, hidden, isDefault } = processCommand(cmd); | ||
gasketBin.addCommand(command, { hidden, isDefault }); | ||
}); | ||
|
||
export default async function ready(gasket) { | ||
gasket.isReady.then(() => { | ||
gasketBin.parse(); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* eslint-disable no-sync */ | ||
import { jest } from '@jest/globals'; | ||
|
||
const mockAddCommand = jest.fn(); | ||
const mockParse = jest.fn(); | ||
const mockProcessCommand = jest.fn(); | ||
|
||
jest.unstable_mockModule('../lib/cli.js', () => { | ||
|
||
return { | ||
gasketBin: { | ||
addCommand: mockAddCommand, | ||
parse: mockParse | ||
}, | ||
processCommand: mockProcessCommand.mockReturnValue({ command: 'test', hidden: false, isDefault: false }) | ||
}; | ||
}); | ||
|
||
const configure = ((await import('../lib/configure.js')).default).handler; | ||
|
||
describe('configure', () => { | ||
let mockGasket, mockConfig; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
mockGasket = { | ||
execSync: jest.fn().mockReturnValue([{ id: 'test', description: 'test', action: jest.fn() }]), | ||
config: { | ||
env: 'development' | ||
} | ||
}; | ||
mockConfig = {}; | ||
}); | ||
|
||
it('should be a function', () => { | ||
expect(configure).toEqual(expect.any(Function)); | ||
}); | ||
|
||
it('should not exec commands if not a gasket command', () => { | ||
configure(mockGasket, mockConfig); | ||
expect(mockGasket.execSync).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('should execute on gasket command', () => { | ||
process.argv = ['node', '/path/to/gasket.js']; | ||
configure(mockGasket, mockConfig); | ||
expect(mockGasket.execSync).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should add commands to gasketBin', () => { | ||
process.argv = ['node', '/path/to/gasket.js']; | ||
configure(mockGasket, mockConfig); | ||
expect(mockAddCommand).toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.