-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b26b808
commit 74ca3ab
Showing
13 changed files
with
640 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,13 +28,14 @@ | |
}, | ||
"imports": { | ||
"@cliffy/command": "jsr:@cliffy/[email protected]", | ||
"@cliffy/testing": "jsr:@cliffy/[email protected]", | ||
"@rebeccastevens/deepmerge": "jsr:@rebeccastevens/deepmerge@^7.1.3", | ||
"@std/assert": "jsr:@std/assert@^1.0.6", | ||
"@std/dotenv": "jsr:@std/dotenv@^0.225.2", | ||
"@std/fmt": "jsr:@std/fmt@^1.0.3", | ||
"@std/jsonc": "jsr:@std/jsonc@^1.0.1", | ||
"@std/path": "jsr:@std/path@^1.0.7", | ||
"@std/streams": "jsr:@std/streams@^1.0.7", | ||
"@std/testing": "jsr:@std/testing@^1.0.3", | ||
"@std/testing": "jsr:@std/testing@^1.0.3" | ||
} | ||
} |
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,49 @@ | ||
import { $, Command, path } from '../deps.ts' | ||
import type { Script, ScriptContext } from '../lib/types.ts' | ||
import { logger } from '../lib/logger.ts' | ||
import { config } from '../lib/config.ts' | ||
|
||
import * as esbuild from 'https://deno.land/x/[email protected]/mod.js' | ||
|
||
import { denoPlugins } from 'jsr:@luca/[email protected]' | ||
|
||
export const script = new Command() | ||
.description('script') | ||
.arguments('<input:string>') | ||
.action(async (options, ...args: string[]) => { | ||
if (!args[0]) { | ||
logger.error('No script name provided') | ||
Deno.exit(1) | ||
} | ||
|
||
try { | ||
const current = Deno.cwd() | ||
const file = `${current}/${args[0]}` | ||
const cfg = config.get() | ||
const context: ScriptContext = { | ||
env: 'dev', | ||
config: cfg, | ||
lib: { | ||
$: $, | ||
path: path, | ||
}, | ||
} | ||
|
||
const builtOutput = `${current}/.runreal/dist/script.esm.js` | ||
|
||
await esbuild.build({ | ||
plugins: [...denoPlugins({ loader: 'portable' })], | ||
entryPoints: [file], | ||
outfile: builtOutput, | ||
bundle: true, | ||
format: 'esm', | ||
}) | ||
esbuild.stop() | ||
|
||
const script = (await import(builtOutput)) as Script | ||
await script.main(context) | ||
} catch (e) { | ||
logger.error(e) | ||
Deno.exit(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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
export * as path from 'jsr:@std/path' | ||
export { mergeReadableStreams } from 'jsr:@std/streams' | ||
|
||
export { $ } from 'jsr:@david/[email protected]' | ||
|
||
export * as dotenv from 'jsr:@std/dotenv' | ||
export * as fmt from 'jsr:@std/fmt/colors' | ||
|
||
|
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,10 @@ | ||
export const snapshot = {}; | ||
|
||
snapshot[`should execute the command 1`] = ` | ||
stdout: | ||
"hello from script | ||
hello from dax | ||
" | ||
stderr: | ||
"" | ||
`; |
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,6 @@ | ||
import type { ScriptContext } from '../../src/lib/types.ts' | ||
|
||
export async function main(ctx: ScriptContext) { | ||
console.log('hello from script') | ||
await ctx.lib.$`echo hello from dax` | ||
} |
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,13 @@ | ||
import { snapshotTest } from '@cliffy/testing' | ||
import { script } from '../src/commands/script.ts' | ||
|
||
await snapshotTest({ | ||
name: 'should execute the command ', | ||
meta: import.meta, | ||
args: ['./tests/fixtures/hello-world.ts'], | ||
// maybe -A | ||
denoArgs: ['--allow-read', '--allow-env', '--allow-write', '--allow-run', '--allow-net'], | ||
async fn() { | ||
await script.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