input-from-script 0.1.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +20 -0
- package/README.md +31 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -0
- package/lib/index.test.d.ts +1 -0
- package/lib/index.test.js +17 -0
- package/lib/index.test.js.map +1 -0
- package/package.json +38 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
'Software'), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<h1 align="center">input-from-script</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center"><code>create</code> input that runs a script.</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://github.com/JoshuaKGoldberg/create/blob/main/.github/CODE_OF_CONDUCT.md" target="_blank"><img alt="🤝 Code of Conduct: Kept" src="https://img.shields.io/badge/%F0%9F%A4%9D_code_of_conduct-kept-21bb42" /></a>
|
|
7
|
+
<a href="https://github.com/JoshuaKGoldberg/create/blob/main/LICENSE.md" target="_blank"><img alt="📝 License: MIT" src="https://img.shields.io/badge/%F0%9F%93%9D_license-MIT-21bb42.svg"></a>
|
|
8
|
+
<a href="http://npmjs.com/package/input-from-script"><img alt="📦 npm version" src="https://img.shields.io/npm/v/input-from-script?color=21bb42&label=%F0%9F%93%A6%20npm" /></a>
|
|
9
|
+
<img alt="💪 TypeScript: Strict" src="https://img.shields.io/badge/%F0%9F%92%AA_typescript-strict-21bb42.svg" />
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
```shell
|
|
13
|
+
npm i input-from-script
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { inputFromScript } from "input-from-script";
|
|
18
|
+
|
|
19
|
+
await take(inputFromScript, { command: "npm whoami" });
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Options
|
|
23
|
+
|
|
24
|
+
`inputFromScript` takes a single argument, `command`, of type `string`.
|
|
25
|
+
|
|
26
|
+
It runs the `command` with [`execa`](https://www.npmjs.com/package/execa) and returns either:
|
|
27
|
+
|
|
28
|
+
- `Error`: If an error was caught running the script
|
|
29
|
+
- `Result`: The type from `execa`, including the `stdout` property
|
|
30
|
+
|
|
31
|
+
See **[create-josh.vercel.app > Engine > Runtime > Inputs](https://create-josh.vercel.app/engine/runtime/inputs)** for more documentation on Inputs.
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createInput } from "create";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export const inputFromScript = createInput({
|
|
4
|
+
args: {
|
|
5
|
+
command: z.string(),
|
|
6
|
+
},
|
|
7
|
+
async produce({ args, runner }) {
|
|
8
|
+
return await runner(args.command);
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC;IAC1C,IAAI,EAAE;QACL,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;KACnB;IACD,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;QAC7B,OAAO,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { testInput } from "create-testers";
|
|
2
|
+
import { describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { inputFromScript } from "./index.js";
|
|
4
|
+
describe("inputFromScript", () => {
|
|
5
|
+
it("returns the result from running the command", async () => {
|
|
6
|
+
const command = "echo 123";
|
|
7
|
+
const expected = { stdout: "123" };
|
|
8
|
+
const runner = vi.fn().mockResolvedValue(expected);
|
|
9
|
+
const actual = await testInput(inputFromScript, {
|
|
10
|
+
args: { command },
|
|
11
|
+
runner,
|
|
12
|
+
});
|
|
13
|
+
expect(actual).toBe(expected);
|
|
14
|
+
expect(runner).toHaveBeenCalledWith(command);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,6CAA6C,EAAE,KAAK,IAAI,EAAE;QAC5D,MAAM,OAAO,GAAG,UAAU,CAAC;QAC3B,MAAM,QAAQ,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QAEnD,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,eAAe,EAAE;YAC/C,IAAI,EAAE,EAAE,OAAO,EAAE;YACjB,MAAM;SACN,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9B,MAAM,CAAC,MAAM,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "input-from-script",
|
|
3
|
+
"version": "0.1.0-alpha.3",
|
|
4
|
+
"description": "create input that runs a script.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/JoshuaKGoldberg/create",
|
|
8
|
+
"directory": "packages/input-from-script"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"author": {
|
|
12
|
+
"name": "Josh Goldberg ✨",
|
|
13
|
+
"email": "npm@joshuakgoldberg.com"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./lib/index.js",
|
|
17
|
+
"files": [
|
|
18
|
+
"lib/",
|
|
19
|
+
"package.json",
|
|
20
|
+
"LICENSE.md",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"zod": "^3.24.1"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"create-testers": "0.1.0-alpha.7"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"create": "0.1.0-alpha.7"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc"
|
|
37
|
+
}
|
|
38
|
+
}
|