-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Closes #2078 BREAKING CHANGE: User files and folders are now symlinked from `/tmp/containerbase/cache` to `/home/ubuntu`.
- Loading branch information
Showing
55 changed files
with
949 additions
and
375 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Cli } from 'clipanion'; | ||
import { describe, expect, test, vi } from 'vitest'; | ||
import { prepareCommands } from '.'; | ||
|
||
const mocks = vi.hoisted(() => ({ | ||
installTool: vi.fn(), | ||
prepareTools: vi.fn(), | ||
initializeTools: vi.fn(), | ||
})); | ||
|
||
vi.mock('../install-tool', () => mocks); | ||
vi.mock('../prepare-tool', () => mocks); | ||
|
||
describe('index', () => { | ||
test('init-tool', async () => { | ||
const cli = new Cli({ binaryName: 'cli' }); | ||
prepareCommands(cli, null); | ||
|
||
expect(await cli.run(['init', 'tool', 'node'])).toBe(0); | ||
expect(mocks.initializeTools).toHaveBeenCalledOnce(); | ||
expect(mocks.initializeTools).toHaveBeenCalledWith(['node'], false); | ||
|
||
mocks.initializeTools.mockRejectedValueOnce(new Error('test')); | ||
expect(await cli.run(['init', 'tool', 'node'])).toBe(1); | ||
}); | ||
}); |
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,47 @@ | ||
import { Command, Option } from 'clipanion'; | ||
import prettyMilliseconds from 'pretty-ms'; | ||
import { initializeTools } from '../prepare-tool'; | ||
import { logger } from '../utils'; | ||
|
||
export class InitToolCommand extends Command { | ||
static override paths = [['init', 'tool']]; | ||
|
||
static override usage = Command.Usage({ | ||
description: | ||
'Initialize a tool into the container. This creates missing files and directories.', | ||
examples: [ | ||
['Initialize node', '$0 init tool node'], | ||
['Initialize all tools', '$0 init tool all'], | ||
], | ||
}); | ||
|
||
tools = Option.Rest({ required: 1 }); | ||
|
||
dryRun = Option.Boolean('-d,--dry-run', false); | ||
|
||
async execute(): Promise<number | void> { | ||
const start = Date.now(); | ||
let error = false; | ||
logger.info(`Initializing tools ${this.tools.join(', ')}...`); | ||
try { | ||
return await initializeTools(this.tools, this.dryRun); | ||
} catch (err) { | ||
error = true; | ||
logger.debug(err); | ||
if (err instanceof Error) { | ||
logger.fatal(err.message); | ||
} | ||
return 1; | ||
} finally { | ||
if (error) { | ||
logger.fatal( | ||
`Initialize tools ${this.tools.join(', ')} failed in ${prettyMilliseconds(Date.now() - start)}.`, | ||
); | ||
} else { | ||
logger.info( | ||
`Initialize tools ${this.tools.join(', ')} succeded in ${prettyMilliseconds(Date.now() - start)}.`, | ||
); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.