@mondaydotcomorg/z2h-cli 0.10.0 → 0.10.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/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +3 -2
- package/dist/esm/commands/deploy.d.ts.map +1 -1
- package/dist/esm/commands/deploy.mjs +3 -2
- package/dist/esm/util/auth/auth-store.d.ts.map +1 -1
- package/dist/esm/util/auth/auth-store.mjs +10 -0
- package/dist/esm/util/machine-identity.d.ts +9 -0
- package/dist/esm/util/machine-identity.d.ts.map +1 -0
- package/dist/esm/util/machine-identity.mjs +12 -0
- package/dist/util/auth/auth-store.d.ts.map +1 -1
- package/dist/util/auth/auth-store.js +10 -0
- package/dist/util/machine-identity.d.ts +9 -0
- package/dist/util/machine-identity.d.ts.map +1 -0
- package/dist/util/machine-identity.js +14 -0
- package/package.json +1 -1
- package/src/commands/deploy.ts +3 -3
- package/src/util/auth/auth-store.ts +12 -0
- package/src/util/machine-identity.ts +10 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAGD,wBAAsB,aAAa,CAAC,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyF3E"}
|
package/dist/commands/deploy.js
CHANGED
|
@@ -11,8 +11,9 @@ const constants = require('../constants.js');
|
|
|
11
11
|
const util_s3_client = require('../util/s3/client.js');
|
|
12
12
|
const util_auth_authStore = require('../util/auth/auth-store.js');
|
|
13
13
|
const util_appName = require('../util/app-name.js');
|
|
14
|
-
const
|
|
14
|
+
const util_machineIdentity = require('../util/machine-identity.js');
|
|
15
15
|
const util_git_repo = require('../util/git/repo.js');
|
|
16
|
+
const commands_build = require('./build.js');
|
|
16
17
|
|
|
17
18
|
const _interopDefault = e => e && e.__esModule ? e : { default: e };
|
|
18
19
|
|
|
@@ -50,7 +51,7 @@ async function deployCommand(opts = {}) {
|
|
|
50
51
|
throw new Error(`Missing asset-manifest.json at ${assetManifestPath}.`);
|
|
51
52
|
}
|
|
52
53
|
const assetManifest = (await fs.readJson(assetManifestPath));
|
|
53
|
-
const deployedBy = os__default.default.userInfo().username;
|
|
54
|
+
const deployedBy = util_machineIdentity.getMachineAppName() ?? os__default.default.userInfo().username;
|
|
54
55
|
const gitRemote = await util_git_repo.getRemoteUrl(process.cwd());
|
|
55
56
|
const entry = {
|
|
56
57
|
...assetManifest,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAGD,wBAAsB,aAAa,CAAC,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyF3E"}
|
|
@@ -9,8 +9,9 @@ import { BUCKET_WRITE_NAME, brokerBaseUrl, BUCKET_READ_DNS_URL } from '../consta
|
|
|
9
9
|
import { setupS3Client } from '../util/s3/client.mjs';
|
|
10
10
|
import { readZthAuth } from '../util/auth/auth-store.mjs';
|
|
11
11
|
import { mfAppName, cleanAppName } from '../util/app-name.mjs';
|
|
12
|
-
import {
|
|
12
|
+
import { getMachineAppName } from '../util/machine-identity.mjs';
|
|
13
13
|
import { getRemoteUrl } from '../util/git/repo.mjs';
|
|
14
|
+
import { buildCommand } from './build.mjs';
|
|
14
15
|
|
|
15
16
|
// Should be run from the consumer app directory — uses process.cwd() to locate it.
|
|
16
17
|
async function deployCommand(opts = {}) {
|
|
@@ -43,7 +44,7 @@ async function deployCommand(opts = {}) {
|
|
|
43
44
|
throw new Error(`Missing asset-manifest.json at ${assetManifestPath}.`);
|
|
44
45
|
}
|
|
45
46
|
const assetManifest = (await readJson(assetManifestPath));
|
|
46
|
-
const deployedBy = os.userInfo().username;
|
|
47
|
+
const deployedBy = getMachineAppName() ?? os.userInfo().username;
|
|
47
48
|
const gitRemote = await getRemoteUrl(process.cwd());
|
|
48
49
|
const entry = {
|
|
49
50
|
...assetManifest,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-store.d.ts","sourceRoot":"","sources":["../../../../src/util/auth/auth-store.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY,QAAkC,CAAC;AAC5D,eAAO,MAAM,aAAa,QAAuC,CAAC;AAElE,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,mBAAoB,SAAQ,KAAK;aAChB,YAAY,EAAE,MAAM;gBAApB,YAAY,EAAE,MAAM;CAIjD;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"auth-store.d.ts","sourceRoot":"","sources":["../../../../src/util/auth/auth-store.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY,QAAkC,CAAC;AAC5D,eAAO,MAAM,aAAa,QAAuC,CAAC;AAElE,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,mBAAoB,SAAQ,KAAK;aAChB,YAAY,EAAE,MAAM;gBAApB,YAAY,EAAE,MAAM;CAIjD;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAkBpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,IAAI,CAUpD"}
|
|
@@ -16,6 +16,13 @@ class Z2hAuthMissingError extends Error {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
async function readZthAuth() {
|
|
19
|
+
if (process.env.Z2H_AUTH_TOKEN) {
|
|
20
|
+
const token = process.env.Z2H_AUTH_TOKEN;
|
|
21
|
+
if (!/^[\w-]+\.[\w-]+\.[\w-]+$/.test(token)) {
|
|
22
|
+
throw new Error('Z2H_AUTH_TOKEN is not a valid JWT (expected three dot-separated segments). Please re-set the environment variable.');
|
|
23
|
+
}
|
|
24
|
+
return { token };
|
|
25
|
+
}
|
|
19
26
|
if (!(await pathExists(Z2H_AUTH_FILE))) {
|
|
20
27
|
throw new Z2hAuthMissingError(Z2H_AUTH_FILE);
|
|
21
28
|
}
|
|
@@ -35,6 +42,9 @@ async function readZthAuth() {
|
|
|
35
42
|
* blow up — and where an inline sync read keeps the spawn call site simple.
|
|
36
43
|
*/
|
|
37
44
|
function tryReadAuthTokenSync() {
|
|
45
|
+
if (process.env.Z2H_AUTH_TOKEN) {
|
|
46
|
+
return process.env.Z2H_AUTH_TOKEN;
|
|
47
|
+
}
|
|
38
48
|
try {
|
|
39
49
|
const parsed = readJsonSync(Z2H_AUTH_FILE);
|
|
40
50
|
return parsed?.token ?? null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the machine app name when running as a service (e.g. agent-runner).
|
|
3
|
+
* Available when the process is a monday.com microservice with `APP_NAME` set
|
|
4
|
+
* by the platform runtime.
|
|
5
|
+
*
|
|
6
|
+
* Returns `undefined` for interactive human users (fallback to os.userInfo).
|
|
7
|
+
*/
|
|
8
|
+
export declare function getMachineAppName(): string | undefined;
|
|
9
|
+
//# sourceMappingURL=machine-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machine-identity.d.ts","sourceRoot":"","sources":["../../../src/util/machine-identity.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAEtD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the machine app name when running as a service (e.g. agent-runner).
|
|
3
|
+
* Available when the process is a monday.com microservice with `APP_NAME` set
|
|
4
|
+
* by the platform runtime.
|
|
5
|
+
*
|
|
6
|
+
* Returns `undefined` for interactive human users (fallback to os.userInfo).
|
|
7
|
+
*/
|
|
8
|
+
function getMachineAppName() {
|
|
9
|
+
return process.env.APP_NAME || undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { getMachineAppName };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-store.d.ts","sourceRoot":"","sources":["../../../src/util/auth/auth-store.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY,QAAkC,CAAC;AAC5D,eAAO,MAAM,aAAa,QAAuC,CAAC;AAElE,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,mBAAoB,SAAQ,KAAK;aAChB,YAAY,EAAE,MAAM;gBAApB,YAAY,EAAE,MAAM;CAIjD;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"auth-store.d.ts","sourceRoot":"","sources":["../../../src/util/auth/auth-store.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY,QAAkC,CAAC;AAC5D,eAAO,MAAM,aAAa,QAAuC,CAAC;AAElE,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,mBAAoB,SAAQ,KAAK;aAChB,YAAY,EAAE,MAAM;gBAApB,YAAY,EAAE,MAAM;CAIjD;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAkBpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,IAAI,CAUpD"}
|
|
@@ -23,6 +23,13 @@ class Z2hAuthMissingError extends Error {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
async function readZthAuth() {
|
|
26
|
+
if (process.env.Z2H_AUTH_TOKEN) {
|
|
27
|
+
const token = process.env.Z2H_AUTH_TOKEN;
|
|
28
|
+
if (!/^[\w-]+\.[\w-]+\.[\w-]+$/.test(token)) {
|
|
29
|
+
throw new Error('Z2H_AUTH_TOKEN is not a valid JWT (expected three dot-separated segments). Please re-set the environment variable.');
|
|
30
|
+
}
|
|
31
|
+
return { token };
|
|
32
|
+
}
|
|
26
33
|
if (!(await fs.pathExists(Z2H_AUTH_FILE))) {
|
|
27
34
|
throw new Z2hAuthMissingError(Z2H_AUTH_FILE);
|
|
28
35
|
}
|
|
@@ -42,6 +49,9 @@ async function readZthAuth() {
|
|
|
42
49
|
* blow up — and where an inline sync read keeps the spawn call site simple.
|
|
43
50
|
*/
|
|
44
51
|
function tryReadAuthTokenSync() {
|
|
52
|
+
if (process.env.Z2H_AUTH_TOKEN) {
|
|
53
|
+
return process.env.Z2H_AUTH_TOKEN;
|
|
54
|
+
}
|
|
45
55
|
try {
|
|
46
56
|
const parsed = fs.readJsonSync(Z2H_AUTH_FILE);
|
|
47
57
|
return parsed?.token ?? null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the machine app name when running as a service (e.g. agent-runner).
|
|
3
|
+
* Available when the process is a monday.com microservice with `APP_NAME` set
|
|
4
|
+
* by the platform runtime.
|
|
5
|
+
*
|
|
6
|
+
* Returns `undefined` for interactive human users (fallback to os.userInfo).
|
|
7
|
+
*/
|
|
8
|
+
export declare function getMachineAppName(): string | undefined;
|
|
9
|
+
//# sourceMappingURL=machine-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machine-identity.d.ts","sourceRoot":"","sources":["../../src/util/machine-identity.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAEtD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns the machine app name when running as a service (e.g. agent-runner).
|
|
5
|
+
* Available when the process is a monday.com microservice with `APP_NAME` set
|
|
6
|
+
* by the platform runtime.
|
|
7
|
+
*
|
|
8
|
+
* Returns `undefined` for interactive human users (fallback to os.userInfo).
|
|
9
|
+
*/
|
|
10
|
+
function getMachineAppName() {
|
|
11
|
+
return process.env.APP_NAME || undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.getMachineAppName = getMachineAppName;
|
package/package.json
CHANGED
package/src/commands/deploy.ts
CHANGED
|
@@ -16,8 +16,9 @@ import { BUCKET_WRITE_NAME, BUCKET_READ_DNS_URL, brokerBaseUrl } from '../consta
|
|
|
16
16
|
import { setupS3Client } from '../util/s3/client';
|
|
17
17
|
import { readZthAuth } from '../util/auth/auth-store';
|
|
18
18
|
import { cleanAppName, mfAppName } from '../util/app-name';
|
|
19
|
-
import {
|
|
19
|
+
import { getMachineAppName } from '../util/machine-identity';
|
|
20
20
|
import { getRemoteUrl } from '../util/git/repo';
|
|
21
|
+
import { buildCommand } from './build';
|
|
21
22
|
|
|
22
23
|
export interface DeployOptions {
|
|
23
24
|
dryRun?: boolean;
|
|
@@ -62,9 +63,8 @@ export async function deployCommand(opts: DeployOptions = {}): Promise<void> {
|
|
|
62
63
|
}
|
|
63
64
|
const assetManifest = (await readJson(assetManifestPath)) as AssetManifestFile;
|
|
64
65
|
|
|
65
|
-
const deployedBy = os.userInfo().username;
|
|
66
|
+
const deployedBy = getMachineAppName() ?? os.userInfo().username;
|
|
66
67
|
const gitRemote = await getRemoteUrl(process.cwd());
|
|
67
|
-
|
|
68
68
|
const entry: ManifestEntry = {
|
|
69
69
|
...assetManifest,
|
|
70
70
|
version,
|
|
@@ -20,6 +20,15 @@ export class Z2hAuthMissingError extends Error {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export async function readZthAuth(): Promise<ZthAuth> {
|
|
23
|
+
if (process.env.Z2H_AUTH_TOKEN) {
|
|
24
|
+
const token = process.env.Z2H_AUTH_TOKEN;
|
|
25
|
+
if (!/^[\w-]+\.[\w-]+\.[\w-]+$/.test(token)) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
'Z2H_AUTH_TOKEN is not a valid JWT (expected three dot-separated segments). Please re-set the environment variable.'
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return { token };
|
|
31
|
+
}
|
|
23
32
|
if (!(await pathExists(Z2H_AUTH_FILE))) {
|
|
24
33
|
throw new Z2hAuthMissingError(Z2H_AUTH_FILE);
|
|
25
34
|
}
|
|
@@ -40,6 +49,9 @@ export async function readZthAuth(): Promise<ZthAuth> {
|
|
|
40
49
|
* blow up — and where an inline sync read keeps the spawn call site simple.
|
|
41
50
|
*/
|
|
42
51
|
export function tryReadAuthTokenSync(): string | null {
|
|
52
|
+
if (process.env.Z2H_AUTH_TOKEN) {
|
|
53
|
+
return process.env.Z2H_AUTH_TOKEN;
|
|
54
|
+
}
|
|
43
55
|
try {
|
|
44
56
|
const parsed = readJsonSync(Z2H_AUTH_FILE) as Partial<ZthAuth> | null;
|
|
45
57
|
return parsed?.token ?? null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the machine app name when running as a service (e.g. agent-runner).
|
|
3
|
+
* Available when the process is a monday.com microservice with `APP_NAME` set
|
|
4
|
+
* by the platform runtime.
|
|
5
|
+
*
|
|
6
|
+
* Returns `undefined` for interactive human users (fallback to os.userInfo).
|
|
7
|
+
*/
|
|
8
|
+
export function getMachineAppName(): string | undefined {
|
|
9
|
+
return process.env.APP_NAME || undefined;
|
|
10
|
+
}
|