mirror of
https://github.com/screenci/screenci.git
synced 2026-09-19 08:57:46 +08:00
Improve image to not build extra image, fix image selection
This commit is contained in:
@@ -51,6 +51,7 @@ jobs:
|
||||
file: Dockerfile
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
provenance: false
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
|
||||
+15
@@ -1718,6 +1718,21 @@ describe('CLI', () => {
|
||||
expect(pkgCall?.[1]).toContain('my-cool-project')
|
||||
})
|
||||
|
||||
it('should use published screenci dependency in generated package.json', async () => {
|
||||
process.argv = ['node', 'cli.js', 'init', 'my-project']
|
||||
mockExistsSync.mockReturnValue(false)
|
||||
|
||||
const { main } = await import('./cli')
|
||||
await main()
|
||||
|
||||
const pkgCall = mockWriteFile.mock.calls.find(
|
||||
(c: unknown[]) =>
|
||||
typeof c[0] === 'string' && c[0].endsWith('package.json')
|
||||
)
|
||||
expect(pkgCall?.[1]).toContain('"screenci": "latest"')
|
||||
expect(pkgCall?.[1]).not.toContain('"screenci": "file:')
|
||||
})
|
||||
|
||||
it('should prompt for project name when not provided as arg', async () => {
|
||||
process.argv = ['node', 'cli.js', 'init']
|
||||
mockExistsSync.mockReturnValue(false)
|
||||
|
||||
@@ -1274,13 +1274,9 @@ export default defineConfig({
|
||||
|
||||
function generatePackageJson(
|
||||
projectName: string,
|
||||
localPackagePath?: string,
|
||||
includePlaywrightCli = false
|
||||
): string {
|
||||
const npmName = projectName.toLowerCase().replace(/[^a-z0-9-]/g, '-')
|
||||
const screenciVersion = localPackagePath
|
||||
? `file:${localPackagePath}`
|
||||
: 'latest'
|
||||
const devDependencies: Record<string, string> = {
|
||||
'@types/node': '^25.0.0',
|
||||
tsx: '^4.21.0',
|
||||
@@ -1301,7 +1297,7 @@ function generatePackageJson(
|
||||
dev: 'screenci dev',
|
||||
},
|
||||
dependencies: {
|
||||
screenci: screenciVersion,
|
||||
screenci: 'latest',
|
||||
},
|
||||
devDependencies,
|
||||
},
|
||||
@@ -1477,7 +1473,6 @@ function checkNodeVersion(): void {
|
||||
|
||||
async function runInit(
|
||||
projectNameArg?: string,
|
||||
localPackagePath?: string,
|
||||
verbose = false
|
||||
): Promise<void> {
|
||||
checkNodeVersion()
|
||||
@@ -1516,7 +1511,7 @@ async function runInit(
|
||||
)
|
||||
await writeFile(
|
||||
resolve(projectDir, 'package.json'),
|
||||
generatePackageJson(dirName, localPackagePath, shouldAddPlaywrightCli)
|
||||
generatePackageJson(dirName, shouldAddPlaywrightCli)
|
||||
)
|
||||
await writeFile(resolve(projectDir, 'Dockerfile'), generateDockerfile())
|
||||
await writeFile(resolve(projectDir, '.gitignore'), generateGitignore())
|
||||
@@ -1879,24 +1874,14 @@ export async function main() {
|
||||
program
|
||||
.command('init [name]')
|
||||
.description('Initialize a new screenci project')
|
||||
.option('--local', 'use local package path (for development)')
|
||||
.option('-v, --verbose', 'verbose output')
|
||||
.action(
|
||||
async (name: string | undefined, options: Record<string, unknown>) => {
|
||||
if (name === 'auth') {
|
||||
await runInitAuth()
|
||||
} else {
|
||||
let localPackagePath: string | undefined
|
||||
if (options['local']) {
|
||||
const cliDir = dirname(fileURLToPath(import.meta.url))
|
||||
// cli.ts is at package root; dist/cli.js is one level down
|
||||
localPackagePath = existsSync(resolve(cliDir, 'package.json'))
|
||||
? cliDir
|
||||
: resolve(cliDir, '..')
|
||||
}
|
||||
await runInit(
|
||||
name,
|
||||
localPackagePath,
|
||||
(options['verbose'] as boolean | undefined) ?? false
|
||||
)
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ npx screenci init my-product
|
||||
|
||||
Options:
|
||||
|
||||
- `--local` uses the local package path when developing ScreenCI itself
|
||||
- `-v, --verbose` prints underlying command output instead of spinners
|
||||
|
||||
## `screenci dev [playwrightArgs...]`
|
||||
|
||||
@@ -34,7 +34,6 @@ my-project/
|
||||
|
||||
- If no name is passed, the command prompts for one.
|
||||
- `--verbose` shows more setup output.
|
||||
- `--local` uses the local package path for development workflows.
|
||||
- After scaffolding, run `npm install`.
|
||||
|
||||
## Typical Flow
|
||||
|
||||
Reference in New Issue
Block a user