@dagger.io/dagger 0.1.0-alpha.4 → 0.1.1
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/api/client.gen.d.ts +67 -26
- package/dist/api/client.gen.d.ts.map +1 -1
- package/dist/api/client.gen.js +566 -336
- package/dist/api/utils.d.ts.map +1 -1
- package/dist/api/utils.js +14 -15
- package/dist/connect.d.ts +7 -6
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/provisioning/bin/bin.d.ts +21 -0
- package/dist/provisioning/bin/bin.d.ts.map +1 -0
- package/dist/provisioning/bin/bin.js +112 -0
- package/dist/provisioning/bin/index.d.ts +2 -0
- package/dist/provisioning/bin/index.d.ts.map +1 -0
- package/dist/provisioning/bin/index.js +1 -0
- package/dist/provisioning/default.d.ts.map +1 -1
- package/dist/provisioning/default.js +2 -1
- package/dist/provisioning/docker-provision/image.d.ts +1 -0
- package/dist/provisioning/docker-provision/image.d.ts.map +1 -1
- package/dist/provisioning/docker-provision/image.js +37 -19
- package/dist/provisioning/docker-provision/index.d.ts +1 -1
- package/dist/provisioning/docker-provision/index.d.ts.map +1 -1
- package/dist/provisioning/docker-provision/index.js +1 -1
- package/dist/provisioning/engineconn.d.ts +3 -2
- package/dist/provisioning/engineconn.d.ts.map +1 -1
- package/dist/provisioning/http/http.d.ts.map +1 -1
- package/dist/provisioning/http/http.js +1 -0
- package/dist/provisioning/http/index.d.ts.map +1 -1
- package/dist/provisioning/index.d.ts +4 -4
- package/dist/provisioning/index.d.ts.map +1 -1
- package/dist/provisioning/index.js +4 -4
- package/dist/provisioning/provisioner.d.ts.map +1 -1
- package/dist/provisioning/provisioner.js +2 -0
- package/package.json +10 -6
- package/dist/api/types.d.ts +0 -302
- package/dist/api/types.d.ts.map +0 -1
- package/dist/api/types.js +0 -1
package/dist/api/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../api/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../api/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,wBAAgB,YAAY,CAAC,CAAC,EAAE,SAAS,EAAE,UAmC1C;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAc1E"}
|
package/dist/api/utils.js
CHANGED
|
@@ -1,41 +1,40 @@
|
|
|
1
1
|
export function queryBuilder(q) {
|
|
2
2
|
const args = (item) => {
|
|
3
|
-
const regex = /\{"[a-zA-Z]+"/
|
|
3
|
+
const regex = /\{"[a-zA-Z]+"/gi;
|
|
4
4
|
const entries = Object.entries(item.args)
|
|
5
|
-
.filter(value => value[1] !== undefined)
|
|
6
|
-
.map(value => {
|
|
7
|
-
if (typeof value[1] ===
|
|
8
|
-
return `${value[0]}: ${JSON.stringify(value[1]).replace(regex, str => str.replace(/"/g,
|
|
5
|
+
.filter((value) => value[1] !== undefined)
|
|
6
|
+
.map((value) => {
|
|
7
|
+
if (typeof value[1] === "object") {
|
|
8
|
+
return `${value[0]}: ${JSON.stringify(value[1]).replace(regex, (str) => str.replace(/"/g, ""))}`;
|
|
9
9
|
}
|
|
10
|
-
if (typeof value[1] ===
|
|
10
|
+
if (typeof value[1] === "number") {
|
|
11
11
|
return `${value[0]}: ${value[1]}`;
|
|
12
12
|
}
|
|
13
13
|
return `${value[0]}: "${value[1]}"`;
|
|
14
14
|
});
|
|
15
15
|
if (entries.length === 0) {
|
|
16
|
-
return
|
|
16
|
+
return "";
|
|
17
17
|
}
|
|
18
|
-
return
|
|
18
|
+
return "(" + entries + ")";
|
|
19
19
|
};
|
|
20
20
|
let query = "{";
|
|
21
21
|
q.forEach((item, index) => {
|
|
22
22
|
query += `
|
|
23
|
-
${item.operation} ${item.args ? `${args(item)}` :
|
|
23
|
+
${item.operation} ${item.args ? `${args(item)}` : ""} ${q.length - 1 !== index ? "{" : "}".repeat(q.length - 1)}
|
|
24
24
|
`;
|
|
25
25
|
});
|
|
26
26
|
query += "}";
|
|
27
|
-
return query.replace(/\s+/g,
|
|
27
|
+
return query.replace(/\s+/g, "");
|
|
28
28
|
}
|
|
29
29
|
export function queryFlatten(res) {
|
|
30
30
|
if (res.errors)
|
|
31
31
|
throw res.errors[0];
|
|
32
|
-
return Object.assign({}, ...function _flatten(o) {
|
|
33
|
-
return [].concat(...Object.keys(o)
|
|
34
|
-
|
|
35
|
-
if (typeof o[k] === 'object' && !(o[k] instanceof Array))
|
|
32
|
+
return Object.assign({}, ...(function _flatten(o) {
|
|
33
|
+
return [].concat(...Object.keys(o).map((k) => {
|
|
34
|
+
if (typeof o[k] === "object" && !(o[k] instanceof Array))
|
|
36
35
|
return _flatten(o[k]);
|
|
37
36
|
else
|
|
38
37
|
return { [k]: o[k] };
|
|
39
38
|
}));
|
|
40
|
-
}(res));
|
|
39
|
+
})(res));
|
|
41
40
|
}
|
package/dist/connect.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import Client from "./api/client.gen.js";
|
|
3
|
+
import { Writable } from "node:stream";
|
|
2
4
|
/**
|
|
3
|
-
* ConnectOpts defines option used to
|
|
4
|
-
* in dev mode.
|
|
5
|
-
* Options are based on `dagger cloak` CLI.
|
|
5
|
+
* ConnectOpts defines option used to connect to an engine.
|
|
6
6
|
*/
|
|
7
7
|
export interface ConnectOpts {
|
|
8
8
|
Workdir?: string;
|
|
9
9
|
ConfigPath?: string;
|
|
10
|
+
LogOutput?: Writable;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
+
type CallbackFct = (client: Client) => Promise<void>;
|
|
12
13
|
/**
|
|
13
|
-
* connect runs
|
|
14
|
+
* connect runs GraphQL server and initializes a
|
|
14
15
|
* GraphQL client to execute query on it through its callback.
|
|
15
16
|
* This implementation is based on the existing Go SDK.
|
|
16
17
|
*/
|
package/dist/connect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../connect.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../connect.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,qBAAqB,CAAA;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,QAAQ,CAAA;CACrB;AAED,KAAK,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;AAEpD;;;;GAIG;AACH,wBAAsB,OAAO,CAC3B,EAAE,EAAE,WAAW,EACf,MAAM,GAAE,WAAgB,GACvB,OAAO,CAAC,IAAI,CAAC,CAgBf"}
|
package/dist/connect.js
CHANGED
|
@@ -7,9 +7,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { getProvisioner, DEFAULT_HOST } from
|
|
10
|
+
import { getProvisioner, DEFAULT_HOST } from "./provisioning/index.js";
|
|
11
11
|
/**
|
|
12
|
-
* connect runs
|
|
12
|
+
* connect runs GraphQL server and initializes a
|
|
13
13
|
* GraphQL client to execute query on it through its callback.
|
|
14
14
|
* This implementation is based on the existing Go SDK.
|
|
15
15
|
*/
|
|
@@ -17,9 +17,9 @@ export function connect(cb, config = {}) {
|
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
// Create config with default values that may be overridden
|
|
19
19
|
// by config if values are set.
|
|
20
|
-
const _config = Object.assign({ Workdir: process.env[
|
|
20
|
+
const _config = Object.assign({ Workdir: process.env["DAGGER_WORKDIR"] || process.cwd(), ConfigPath: process.env["DAGGER_CONFIG"] || "./dagger.json" }, config);
|
|
21
21
|
// set host to be DAGGER_HOST env otherwise to provisioning defaults
|
|
22
|
-
const host = process.env[
|
|
22
|
+
const host = process.env["DAGGER_HOST"] || DEFAULT_HOST;
|
|
23
23
|
const provisioner = getProvisioner(host);
|
|
24
24
|
yield cb(yield provisioner.Connect(_config)).finally(() => __awaiter(this, void 0, void 0, function* () { return provisioner.Close(); }));
|
|
25
25
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Client from "./api/client.gen.js";
|
|
2
2
|
export { gql } from "graphql-tag";
|
|
3
3
|
export { GraphQLClient } from "graphql-request";
|
|
4
|
-
export { connect, ConnectOpts } from
|
|
5
|
-
export { getProvisioner } from
|
|
4
|
+
export { connect, ConnectOpts } from "./connect.js";
|
|
5
|
+
export { getProvisioner } from "./provisioning/index.js";
|
|
6
6
|
export default Client;
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,qBAAqB,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,eAAe,MAAM,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Client from "./api/client.gen.js";
|
|
2
2
|
export { gql } from "graphql-tag";
|
|
3
3
|
export { GraphQLClient } from "graphql-request";
|
|
4
|
-
export { connect } from
|
|
5
|
-
export { getProvisioner } from
|
|
4
|
+
export { connect } from "./connect.js";
|
|
5
|
+
export { getProvisioner } from "./provisioning/index.js";
|
|
6
6
|
export default Client;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ConnectOpts, EngineConn } from "../engineconn.js";
|
|
2
|
+
import Client from "../../api/client.gen.js";
|
|
3
|
+
/**
|
|
4
|
+
* Bin runs an engine session from a specified binary
|
|
5
|
+
*/
|
|
6
|
+
export declare class Bin implements EngineConn {
|
|
7
|
+
private subProcess?;
|
|
8
|
+
private path;
|
|
9
|
+
constructor(u: URL);
|
|
10
|
+
Addr(): string;
|
|
11
|
+
Connect(opts: ConnectOpts): Promise<Client>;
|
|
12
|
+
/**
|
|
13
|
+
* runEngineSession execute the engine binary and set up a GraphQL client that
|
|
14
|
+
* target this engine.
|
|
15
|
+
* TODO:(sipsma) dedupe this with equivalent code in image.ts
|
|
16
|
+
*/
|
|
17
|
+
private runEngineSession;
|
|
18
|
+
private readPort;
|
|
19
|
+
Close(): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=bin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../../provisioning/bin/bin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAG1D,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAE5C;;GAEG;AACH,qBAAa,GAAI,YAAW,UAAU;IACpC,OAAO,CAAC,UAAU,CAAC,CAAmB;IAEtC,OAAO,CAAC,IAAI,CAAQ;gBAER,CAAC,EAAE,GAAG;IAQlB,IAAI,IAAI,MAAM;IAIR,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjD;;;;OAIG;YACW,gBAAgB;YAqChB,QAAQ;IAShB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7B"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
11
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
12
|
+
var m = o[Symbol.asyncIterator], i;
|
|
13
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
14
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
15
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
16
|
+
};
|
|
17
|
+
import readline from "readline";
|
|
18
|
+
import { execaCommand } from "execa";
|
|
19
|
+
import Client from "../../api/client.gen.js";
|
|
20
|
+
/**
|
|
21
|
+
* Bin runs an engine session from a specified binary
|
|
22
|
+
*/
|
|
23
|
+
export class Bin {
|
|
24
|
+
constructor(u) {
|
|
25
|
+
this.path = u.host + u.pathname;
|
|
26
|
+
if (this.path == "") {
|
|
27
|
+
// this results in execa looking for it in the $PATH
|
|
28
|
+
this.path = "dagger-engine-session";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
Addr() {
|
|
32
|
+
return "http://dagger";
|
|
33
|
+
}
|
|
34
|
+
Connect(opts) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
return this.runEngineSession(this.path, opts);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* runEngineSession execute the engine binary and set up a GraphQL client that
|
|
41
|
+
* target this engine.
|
|
42
|
+
* TODO:(sipsma) dedupe this with equivalent code in image.ts
|
|
43
|
+
*/
|
|
44
|
+
runEngineSession(engineSessionBinPath, opts) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const engineSessionArgs = [engineSessionBinPath];
|
|
47
|
+
if (opts.Workdir) {
|
|
48
|
+
engineSessionArgs.push("--workdir", opts.Workdir);
|
|
49
|
+
}
|
|
50
|
+
if (opts.Project) {
|
|
51
|
+
engineSessionArgs.push("--project", opts.Project);
|
|
52
|
+
}
|
|
53
|
+
this.subProcess = execaCommand(engineSessionArgs.join(" "), {
|
|
54
|
+
stderr: opts.LogOutput || "ignore",
|
|
55
|
+
// Kill the process if parent exit.
|
|
56
|
+
cleanup: true,
|
|
57
|
+
});
|
|
58
|
+
const stdoutReader = readline.createInterface({
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
60
|
+
input: this.subProcess.stdout,
|
|
61
|
+
});
|
|
62
|
+
const port = yield Promise.race([
|
|
63
|
+
this.readPort(stdoutReader),
|
|
64
|
+
new Promise((_, reject) => {
|
|
65
|
+
setTimeout(() => {
|
|
66
|
+
reject(new Error("timeout reading port from engine session"));
|
|
67
|
+
}, 300000).unref(); // long timeout to account for extensions, though that should be optimized in future
|
|
68
|
+
}),
|
|
69
|
+
]);
|
|
70
|
+
return new Client({ host: `127.0.0.1:${port}` });
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
readPort(stdoutReader) {
|
|
74
|
+
var _a, stdoutReader_1, stdoutReader_1_1;
|
|
75
|
+
var _b, e_1, _c, _d;
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
try {
|
|
78
|
+
for (_a = true, stdoutReader_1 = __asyncValues(stdoutReader); stdoutReader_1_1 = yield stdoutReader_1.next(), _b = stdoutReader_1_1.done, !_b;) {
|
|
79
|
+
_d = stdoutReader_1_1.value;
|
|
80
|
+
_a = false;
|
|
81
|
+
try {
|
|
82
|
+
const line = _d;
|
|
83
|
+
// Read line as a port number
|
|
84
|
+
const port = parseInt(line);
|
|
85
|
+
return port;
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
_a = true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
93
|
+
finally {
|
|
94
|
+
try {
|
|
95
|
+
if (!_a && !_b && (_c = stdoutReader_1.return)) yield _c.call(stdoutReader_1);
|
|
96
|
+
}
|
|
97
|
+
finally { if (e_1) throw e_1.error; }
|
|
98
|
+
}
|
|
99
|
+
throw new Error("failed to read port from engine session");
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
Close() {
|
|
103
|
+
var _a;
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
if ((_a = this.subProcess) === null || _a === void 0 ? void 0 : _a.pid) {
|
|
106
|
+
this.subProcess.kill("SIGTERM", {
|
|
107
|
+
forceKillAfterTimeout: 2000,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../provisioning/bin/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./bin.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../provisioning/default.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../provisioning/default.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,QAAwC,CAAA"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
// Code generated by dagger. DO NOT EDIT.
|
|
2
|
+
const DEFAULT_IMAGE_REF = "ghcr.io/dagger/engine:v0.3.5@sha256:41f71f0036167fcc8b926792b079d840c52066eec093f3e177881468fd122c83";
|
|
2
3
|
export const DEFAULT_HOST = `docker-image://${DEFAULT_IMAGE_REF}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../provisioning/docker-provision/image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../provisioning/docker-provision/image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAM1D,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAqD5C;;;GAGG;AACH,qBAAa,WAAY,YAAW,UAAU;IAC5C,OAAO,CAAC,QAAQ,CAAU;IAE1B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAGxB;IAED,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAA0B;IAEvE,OAAO,CAAC,UAAU,CAAC,CAAmB;gBAE1B,CAAC,EAAE,GAAG;IAIlB;;OAEG;IACH,OAAO,CAAC,WAAW;IAInB,IAAI,IAAI,MAAM;IAIR,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAWjD;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc;IAItB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAWpB;;OAEG;IACH,OAAO,CAAC,cAAc;IAStB;;OAEG;IACH,OAAO,CAAC,YAAY;IASpB;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IA+D5B;;;OAGG;YACW,gBAAgB;YA4ChB,QAAQ;IAShB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7B"}
|
|
@@ -70,7 +70,7 @@ export class DockerImage {
|
|
|
70
70
|
* Generate a unix timestamp in nanosecond
|
|
71
71
|
*/
|
|
72
72
|
getRandomId() {
|
|
73
|
-
return
|
|
73
|
+
return process.hrtime.bigint().toString();
|
|
74
74
|
}
|
|
75
75
|
Addr() {
|
|
76
76
|
return "http://dagger";
|
|
@@ -194,13 +194,12 @@ export class DockerImage {
|
|
|
194
194
|
* target this engine.
|
|
195
195
|
*/
|
|
196
196
|
runEngineSession(engineSessionBinPath, opts) {
|
|
197
|
-
var e_1, _a;
|
|
198
197
|
return __awaiter(this, void 0, void 0, function* () {
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
];
|
|
198
|
+
const env = process.env;
|
|
199
|
+
if (!env.DAGGER_RUNNER_HOST) {
|
|
200
|
+
env.DAGGER_RUNNER_HOST = `docker-image://${this.imageRef.Ref}`;
|
|
201
|
+
}
|
|
202
|
+
const engineSessionArgs = [engineSessionBinPath];
|
|
204
203
|
if (opts.Workdir) {
|
|
205
204
|
engineSessionArgs.push("--workdir", opts.Workdir);
|
|
206
205
|
}
|
|
@@ -208,34 +207,53 @@ export class DockerImage {
|
|
|
208
207
|
engineSessionArgs.push("--project", opts.Project);
|
|
209
208
|
}
|
|
210
209
|
this.subProcess = execaCommand(engineSessionArgs.join(" "), {
|
|
211
|
-
stderr: opts.
|
|
210
|
+
stderr: opts.LogOutput || "ignore",
|
|
212
211
|
// Kill the process if parent exit.
|
|
213
212
|
cleanup: true,
|
|
213
|
+
env: env,
|
|
214
214
|
});
|
|
215
215
|
const stdoutReader = readline.createInterface({
|
|
216
216
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
217
217
|
input: this.subProcess.stdout,
|
|
218
218
|
});
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
219
|
+
const port = yield Promise.race([
|
|
220
|
+
this.readPort(stdoutReader),
|
|
221
|
+
new Promise((_, reject) => {
|
|
222
|
+
setTimeout(() => {
|
|
223
|
+
reject(new Error("timeout reading port from engine session"));
|
|
224
|
+
}, 300000).unref(); // long timeout to account for extensions, though that should be optimized in future
|
|
225
|
+
}),
|
|
226
|
+
]);
|
|
227
|
+
return new Client({ host: `127.0.0.1:${port}` });
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
readPort(stdoutReader) {
|
|
231
|
+
var _a, stdoutReader_1, stdoutReader_1_1;
|
|
232
|
+
var _b, e_1, _c, _d;
|
|
233
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
222
234
|
try {
|
|
223
|
-
for (
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
235
|
+
for (_a = true, stdoutReader_1 = __asyncValues(stdoutReader); stdoutReader_1_1 = yield stdoutReader_1.next(), _b = stdoutReader_1_1.done, !_b;) {
|
|
236
|
+
_d = stdoutReader_1_1.value;
|
|
237
|
+
_a = false;
|
|
238
|
+
try {
|
|
239
|
+
const line = _d;
|
|
240
|
+
// Read line as a port number
|
|
241
|
+
const port = parseInt(line);
|
|
242
|
+
return port;
|
|
243
|
+
}
|
|
244
|
+
finally {
|
|
245
|
+
_a = true;
|
|
246
|
+
}
|
|
229
247
|
}
|
|
230
248
|
}
|
|
231
249
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
232
250
|
finally {
|
|
233
251
|
try {
|
|
234
|
-
if (
|
|
252
|
+
if (!_a && !_b && (_c = stdoutReader_1.return)) yield _c.call(stdoutReader_1);
|
|
235
253
|
}
|
|
236
254
|
finally { if (e_1) throw e_1.error; }
|
|
237
255
|
}
|
|
238
|
-
throw new Error("failed to
|
|
256
|
+
throw new Error("failed to read port from engine session");
|
|
239
257
|
});
|
|
240
258
|
}
|
|
241
259
|
Close() {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./image.js";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../provisioning/docker-provision/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../provisioning/docker-provision/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./image.js";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import Client from "../api/client.gen.js";
|
|
2
|
-
import {
|
|
3
|
+
import { Writable } from "node:stream";
|
|
3
4
|
export interface ConnectOpts {
|
|
4
5
|
Workdir?: string;
|
|
5
6
|
Project?: string;
|
|
6
|
-
|
|
7
|
+
LogOutput?: Writable;
|
|
7
8
|
Timeout?: number;
|
|
8
9
|
}
|
|
9
10
|
export interface EngineConn {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engineconn.d.ts","sourceRoot":"","sources":["../../provisioning/engineconn.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"engineconn.d.ts","sourceRoot":"","sources":["../../provisioning/engineconn.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,sBAAsB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,QAAQ,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,IAAI,EAAE,MAAM,MAAM,CAAA;IAElB;;;OAGG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IAE/C;;OAEG;IACH,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../provisioning/http/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../provisioning/http/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAE5C;;;GAGG;AACH,qBAAa,IAAK,YAAW,UAAU;IACrC,OAAO,CAAC,GAAG,CAAK;gBAEJ,CAAC,EAAE,GAAG;IAIlB,IAAI,IAAI,MAAM;IAKR,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAI3C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../provisioning/http/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../provisioning/http/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from "./docker-provision/index.js";
|
|
2
|
+
export * from "./default.js";
|
|
3
|
+
export * from "./engineconn.js";
|
|
4
|
+
export * from "./provisioner.js";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../provisioning/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../provisioning/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA;AAC3C,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from "./docker-provision/index.js";
|
|
2
|
+
export * from "./default.js";
|
|
3
|
+
export * from "./engineconn.js";
|
|
4
|
+
export * from "./provisioner.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provisioner.d.ts","sourceRoot":"","sources":["../../provisioning/provisioner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"provisioner.d.ts","sourceRoot":"","sources":["../../provisioning/provisioner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAa5C;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAWvD"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { DockerImage } from "./docker-provision/image.js";
|
|
2
2
|
import { HTTP } from "./http/http.js";
|
|
3
|
+
import { Bin } from "./bin/bin.js";
|
|
3
4
|
const provisioners = {
|
|
4
5
|
"docker-image": (u) => new DockerImage(u),
|
|
5
6
|
http: (u) => new HTTP(u),
|
|
7
|
+
bin: (u) => new Bin(u),
|
|
6
8
|
};
|
|
7
9
|
/**
|
|
8
10
|
* getProvisioner returns a ready to use Engine connector.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dagger.io/dagger",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"author": "hello@dagger.io",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -22,25 +22,29 @@
|
|
|
22
22
|
"graphql": "^16.5.0",
|
|
23
23
|
"graphql-request": "^5.0.0",
|
|
24
24
|
"graphql-tag": "^2.12.6",
|
|
25
|
-
"node-fetch": "^3.
|
|
25
|
+
"node-fetch": "^3.3.0"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "tsc",
|
|
29
29
|
"test": "mocha",
|
|
30
30
|
"gen:typedoc": "yarn typedoc",
|
|
31
|
-
"lint": "yarn eslint ."
|
|
31
|
+
"lint": "yarn eslint --max-warnings=0 .",
|
|
32
|
+
"fmt": "yarn eslint --fix"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@types/mocha": "latest",
|
|
35
36
|
"@types/node": "~16",
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
37
|
-
"@typescript-eslint/parser": "^5.
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^5.43.0",
|
|
38
|
+
"@typescript-eslint/parser": "^5.43.0",
|
|
38
39
|
"eslint": "^8.27.0",
|
|
40
|
+
"eslint-config-prettier": "^8.5.0",
|
|
41
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
39
42
|
"mocha": "^10.1.0",
|
|
43
|
+
"prettier": "^2.7.1",
|
|
40
44
|
"ts-node": "^10.9.1",
|
|
41
45
|
"typedoc": "^0.23.21",
|
|
42
46
|
"typedoc-plugin-markdown": "^3.13.6",
|
|
43
47
|
"typedoc-plugin-missing-exports": "^1.0.0",
|
|
44
|
-
"typescript": "^4.
|
|
48
|
+
"typescript": "^4.9.3"
|
|
45
49
|
}
|
|
46
50
|
}
|