-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
@remotion/cli: Update skills commands
#9940
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b7609f2
`@remotion/cli`: Update skills commands
JonnyBurger b8d4225
`@remotion/cli`: Verify skills update list
JonnyBurger 8e6565b
`@remotion/cli`: Make skills test cross-platform
JonnyBurger ff0bcbc
Merge remote-tracking branch 'origin/main' into codex/update-skills-c…
JonnyBurger 18fa899
`@remotion/studio-server`: Fix Element install test fixture
JonnyBurger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,118 @@ | ||
| import {expect, test} from 'bun:test'; | ||
| import {spawn} from 'node:child_process'; | ||
| import { | ||
| chmodSync, | ||
| mkdtempSync, | ||
| readdirSync, | ||
| readFileSync, | ||
| rmSync, | ||
| writeFileSync, | ||
| } from 'node:fs'; | ||
| import {tmpdir} from 'node:os'; | ||
| import path from 'node:path'; | ||
|
|
||
| const runSkillsCommand = ({ | ||
| args, | ||
| fakeNpxDirectory, | ||
| outputFile, | ||
| }: { | ||
| args: string[]; | ||
| fakeNpxDirectory: string; | ||
| outputFile: string; | ||
| }) => { | ||
| return new Promise<void>((resolve, reject) => { | ||
| const cliPath = path.join(__dirname, '..', '..', 'remotion-cli.js'); | ||
| const child = spawn(process.execPath, [cliPath, 'skills', ...args], { | ||
| env: { | ||
| ...process.env, | ||
| PATH: `${fakeNpxDirectory}${path.delimiter}${process.env.PATH}`, | ||
| REMOTION_SKILLS_TEST_OUTPUT: outputFile, | ||
| }, | ||
| stdio: 'inherit', | ||
| }); | ||
|
|
||
| child.on('error', reject); | ||
| child.on('exit', (code) => { | ||
| if (code === 0) { | ||
| resolve(); | ||
| } else { | ||
| reject(new Error(`Remotion CLI exited with code ${code}`)); | ||
| } | ||
| }); | ||
| }); | ||
| }; | ||
|
|
||
| test('forwards the correct arguments to the skills CLI', async () => { | ||
| const temporaryDirectory = mkdtempSync( | ||
| path.join(tmpdir(), 'remotion-skills-cli-'), | ||
| ); | ||
| const fakeNpxPath = path.join( | ||
| temporaryDirectory, | ||
| process.platform === 'win32' ? 'npx.cmd' : 'npx', | ||
| ); | ||
| const outputFile = path.join(temporaryDirectory, 'arguments.jsonl'); | ||
| const fakeNpxScript = `import {appendFileSync} from 'node:fs'; | ||
| appendFileSync(process.env.REMOTION_SKILLS_TEST_OUTPUT, JSON.stringify(process.argv.slice(2)) + '\\n'); | ||
| `; | ||
|
|
||
| try { | ||
| if (process.platform === 'win32') { | ||
| const fakeNpxScriptPath = path.join(temporaryDirectory, 'fake-npx.mjs'); | ||
| writeFileSync(fakeNpxScriptPath, fakeNpxScript); | ||
| writeFileSync( | ||
| fakeNpxPath, | ||
| `@"${process.execPath}" "${fakeNpxScriptPath}" %*\r\n`, | ||
| ); | ||
| } else { | ||
| writeFileSync(fakeNpxPath, `#!${process.execPath}\n${fakeNpxScript}`); | ||
| chmodSync(fakeNpxPath, 0o755); | ||
| } | ||
|
|
||
| await runSkillsCommand({ | ||
| args: ['add'], | ||
| fakeNpxDirectory: temporaryDirectory, | ||
| outputFile, | ||
| }); | ||
| await runSkillsCommand({ | ||
| args: ['update'], | ||
| fakeNpxDirectory: temporaryDirectory, | ||
| outputFile, | ||
| }); | ||
|
|
||
| const [addArguments, updateArguments] = readFileSync(outputFile, 'utf8') | ||
| .trim() | ||
| .split('\n') | ||
| .map((line) => JSON.parse(line)); | ||
| const skillsDirectory = path.join( | ||
| __dirname, | ||
| '..', | ||
| '..', | ||
| '..', | ||
| 'skills', | ||
| 'skills', | ||
| ); | ||
| const remotionSkillNames = readdirSync(skillsDirectory, { | ||
| withFileTypes: true, | ||
| }) | ||
| .filter((entry) => entry.isDirectory()) | ||
| .map((entry) => entry.name) | ||
| .sort(); | ||
|
|
||
| expect(addArguments).toEqual([ | ||
| '--loglevel=error', | ||
| 'skills@1.5.20', | ||
| 'add', | ||
| 'remotion-dev/skills', | ||
| '--yes', | ||
| ]); | ||
| expect(updateArguments).toEqual([ | ||
| '--loglevel=error', | ||
| 'skills', | ||
| 'update', | ||
| ...remotionSkillNames, | ||
| '--yes', | ||
| ]); | ||
| } finally { | ||
| rmSync(temporaryDirectory, {recursive: true, force: true}); | ||
| } | ||
| }); |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The old code passed
-yas annpxflag to suppress the installation confirmation prompt. The new code removes it and puts--yesat the end of the arg list, which is passed to theskillsCLI rather than tonpx. Ifskills@1.5.20is not already cached,npxwill prompt interactively. Consider keeping-yin thenpxargs (before the package name) as a belt-and-suspenders measure alongside the--yesfor the skills CLI.