@enspirit/emb 0.6.0 → 0.7.0
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/README.md +1 -1
- package/dist/src/cli/commands/containers/index.js +1 -1
- package/dist/src/config/schema.json +3 -0
- package/dist/src/monorepo/operations/fs/CreateFileOperation.d.ts +2 -0
- package/dist/src/monorepo/operations/fs/CreateFileOperation.js +18 -4
- package/dist/src/monorepo/resources/FileResourceBuilder.d.ts +2 -0
- package/dist/src/monorepo/resources/FileResourceBuilder.js +2 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ export default class ContainersIndex extends BaseCommand {
|
|
|
36
36
|
id: shortId(c.Id),
|
|
37
37
|
image: c.Image,
|
|
38
38
|
name: c.Names[0] || c.Id,
|
|
39
|
-
ports: c.Ports
|
|
39
|
+
ports: c.Ports?.map((p) => {
|
|
40
40
|
const parts = [];
|
|
41
41
|
if (p.IP) {
|
|
42
42
|
parts.push(p.IP, ':', p.PublicPort, '->');
|
|
@@ -3,6 +3,8 @@ import * as z from 'zod';
|
|
|
3
3
|
import { AbstractOperation } from '../../../operations/index.js';
|
|
4
4
|
declare const schema: z.ZodObject<{
|
|
5
5
|
path: z.ZodString;
|
|
6
|
+
script: z.ZodOptional<z.ZodString>;
|
|
7
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
6
8
|
force: z.ZodOptional<z.ZodBoolean>;
|
|
7
9
|
}, z.core.$strip>;
|
|
8
10
|
export declare class CreateFileOperation extends AbstractOperation<typeof schema, unknown> {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { execa } from 'execa';
|
|
1
2
|
import { open, statfs, utimes } from 'node:fs/promises';
|
|
2
3
|
import * as z from 'zod';
|
|
3
4
|
import { AbstractOperation } from '../../../operations/index.js';
|
|
4
5
|
const schema = z.object({
|
|
5
6
|
//
|
|
6
7
|
path: z.string().describe('Path to the file to create'),
|
|
8
|
+
script: z.string().optional().describe('The script to generate the file'),
|
|
9
|
+
cwd: z.string().optional().describe('Working directory to execute scripts'),
|
|
7
10
|
force: z
|
|
8
11
|
.boolean()
|
|
9
12
|
.optional()
|
|
@@ -16,6 +19,7 @@ export class CreateFileOperation extends AbstractOperation {
|
|
|
16
19
|
this.out = out;
|
|
17
20
|
}
|
|
18
21
|
async _run(input) {
|
|
22
|
+
// Check if the file exists, if so our work is done here
|
|
19
23
|
try {
|
|
20
24
|
await statfs(input.path);
|
|
21
25
|
if (input.force) {
|
|
@@ -23,11 +27,21 @@ export class CreateFileOperation extends AbstractOperation {
|
|
|
23
27
|
}
|
|
24
28
|
}
|
|
25
29
|
catch (error) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
// Ignore ENOENT error (file does not exist)
|
|
31
|
+
if (error?.code !== 'ENOENT') {
|
|
32
|
+
throw error;
|
|
29
33
|
}
|
|
30
|
-
|
|
34
|
+
}
|
|
35
|
+
if (input.script) {
|
|
36
|
+
await execa(input.script, {
|
|
37
|
+
all: true,
|
|
38
|
+
cwd: input.cwd,
|
|
39
|
+
shell: true,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const fn = await open(input.path, 'a');
|
|
44
|
+
fn.close();
|
|
31
45
|
}
|
|
32
46
|
}
|
|
33
47
|
}
|
|
@@ -9,6 +9,8 @@ export declare class FileResourceBuilder implements IResourceBuilder<OpInput<Cre
|
|
|
9
9
|
build(resource: ResourceInfo<OpInput<CreateFileOperation>>, out?: Writable): Promise<{
|
|
10
10
|
input: {
|
|
11
11
|
path: string;
|
|
12
|
+
script?: string | undefined;
|
|
13
|
+
cwd?: string | undefined;
|
|
12
14
|
force?: boolean | undefined;
|
|
13
15
|
};
|
|
14
16
|
operation: CreateFileOperation;
|
|
@@ -11,6 +11,8 @@ export class FileResourceBuilder {
|
|
|
11
11
|
async build(resource, out) {
|
|
12
12
|
const input = {
|
|
13
13
|
path: await this.context.component.join(this.context.config.params?.path || this.context.config.name),
|
|
14
|
+
script: resource.params?.script,
|
|
15
|
+
cwd: this.context.component.join('./'),
|
|
14
16
|
};
|
|
15
17
|
return {
|
|
16
18
|
input,
|
package/oclif.manifest.json
CHANGED