@dxos/cli 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/LICENSE +21 -0
- package/README.md +616 -0
- package/bin/dev +17 -0
- package/bin/dev.cmd +3 -0
- package/bin/run +5 -0
- package/bin/run.cmd +3 -0
- package/dist/src/base-command.d.ts +34 -0
- package/dist/src/base-command.d.ts.map +1 -0
- package/dist/src/base-command.js +193 -0
- package/dist/src/base-command.js.map +1 -0
- package/dist/src/commands/app/create.d.ts +17 -0
- package/dist/src/commands/app/create.d.ts.map +1 -0
- package/dist/src/commands/app/create.js +78 -0
- package/dist/src/commands/app/create.js.map +1 -0
- package/dist/src/commands/app/list.d.ts +7 -0
- package/dist/src/commands/app/list.d.ts.map +1 -0
- package/dist/src/commands/app/list.js +31 -0
- package/dist/src/commands/app/list.js.map +1 -0
- package/dist/src/commands/app/publish.d.ts +14 -0
- package/dist/src/commands/app/publish.d.ts.map +1 -0
- package/dist/src/commands/app/publish.js +63 -0
- package/dist/src/commands/app/publish.js.map +1 -0
- package/dist/src/commands/config/index.d.ts +7 -0
- package/dist/src/commands/config/index.d.ts.map +1 -0
- package/dist/src/commands/config/index.js +18 -0
- package/dist/src/commands/config/index.js.map +1 -0
- package/dist/src/commands/config/index.test.d.ts +2 -0
- package/dist/src/commands/config/index.test.d.ts.map +1 -0
- package/dist/src/commands/config/index.test.js +52 -0
- package/dist/src/commands/config/index.test.js.map +1 -0
- package/dist/src/commands/halo/create.d.ts +10 -0
- package/dist/src/commands/halo/create.d.ts.map +1 -0
- package/dist/src/commands/halo/create.js +34 -0
- package/dist/src/commands/halo/create.js.map +1 -0
- package/dist/src/commands/halo/index.d.ts +7 -0
- package/dist/src/commands/halo/index.d.ts.map +1 -0
- package/dist/src/commands/halo/index.js +35 -0
- package/dist/src/commands/halo/index.js.map +1 -0
- package/dist/src/commands/halo/recover.d.ts +10 -0
- package/dist/src/commands/halo/recover.d.ts.map +1 -0
- package/dist/src/commands/halo/recover.js +35 -0
- package/dist/src/commands/halo/recover.js.map +1 -0
- package/dist/src/commands/reset/index.d.ts +6 -0
- package/dist/src/commands/reset/index.d.ts.map +1 -0
- package/dist/src/commands/reset/index.js +24 -0
- package/dist/src/commands/reset/index.js.map +1 -0
- package/dist/src/commands/shell/index.d.ts +7 -0
- package/dist/src/commands/shell/index.d.ts.map +1 -0
- package/dist/src/commands/shell/index.js +27 -0
- package/dist/src/commands/shell/index.js.map +1 -0
- package/dist/src/commands/space/create.d.ts +10 -0
- package/dist/src/commands/space/create.d.ts.map +1 -0
- package/dist/src/commands/space/create.js +39 -0
- package/dist/src/commands/space/create.js.map +1 -0
- package/dist/src/commands/space/index.d.ts +6 -0
- package/dist/src/commands/space/index.d.ts.map +1 -0
- package/dist/src/commands/space/index.js +18 -0
- package/dist/src/commands/space/index.js.map +1 -0
- package/dist/src/commands/space/invite.d.ts +9 -0
- package/dist/src/commands/space/invite.d.ts.map +1 -0
- package/dist/src/commands/space/invite.js +59 -0
- package/dist/src/commands/space/invite.js.map +1 -0
- package/dist/src/commands/space/join.d.ts +13 -0
- package/dist/src/commands/space/join.d.ts.map +1 -0
- package/dist/src/commands/space/join.js +55 -0
- package/dist/src/commands/space/join.js.map +1 -0
- package/dist/src/commands/space/list.d.ts +19 -0
- package/dist/src/commands/space/list.d.ts.map +1 -0
- package/dist/src/commands/space/list.js +28 -0
- package/dist/src/commands/space/list.js.map +1 -0
- package/dist/src/commands/space/members.d.ts +22 -0
- package/dist/src/commands/space/members.d.ts.map +1 -0
- package/dist/src/commands/space/members.js +43 -0
- package/dist/src/commands/space/members.js.map +1 -0
- package/dist/src/hooks/init/config.d.ts +4 -0
- package/dist/src/hooks/init/config.d.ts.map +1 -0
- package/dist/src/hooks/init/config.js +10 -0
- package/dist/src/hooks/init/config.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/util/index.d.ts +4 -0
- package/dist/src/util/index.d.ts.map +1 -0
- package/dist/src/util/index.js +23 -0
- package/dist/src/util/index.js.map +1 -0
- package/dist/src/util/publish/build.d.ts +11 -0
- package/dist/src/util/publish/build.d.ts.map +1 -0
- package/dist/src/util/publish/build.js +26 -0
- package/dist/src/util/publish/build.js.map +1 -0
- package/dist/src/util/publish/common.d.ts +10 -0
- package/dist/src/util/publish/common.d.ts.map +1 -0
- package/dist/src/util/publish/common.js +29 -0
- package/dist/src/util/publish/common.js.map +1 -0
- package/dist/src/util/publish/config.d.ts +3 -0
- package/dist/src/util/publish/config.d.ts.map +1 -0
- package/dist/src/util/publish/config.js +35 -0
- package/dist/src/util/publish/config.js.map +1 -0
- package/dist/src/util/publish/index.d.ts +7 -0
- package/dist/src/util/publish/index.d.ts.map +1 -0
- package/dist/src/util/publish/index.js +26 -0
- package/dist/src/util/publish/index.js.map +1 -0
- package/dist/src/util/publish/ipfs-upload.d.ts +10 -0
- package/dist/src/util/publish/ipfs-upload.d.ts.map +1 -0
- package/dist/src/util/publish/ipfs-upload.js +43 -0
- package/dist/src/util/publish/ipfs-upload.js.map +1 -0
- package/dist/src/util/publish/publish.d.ts +16 -0
- package/dist/src/util/publish/publish.d.ts.map +1 -0
- package/dist/src/util/publish/publish.js +47 -0
- package/dist/src/util/publish/publish.js.map +1 -0
- package/dist/src/util/publish/publisher-rpc-peer.d.ts +15 -0
- package/dist/src/util/publish/publisher-rpc-peer.d.ts.map +1 -0
- package/dist/src/util/publish/publisher-rpc-peer.js +88 -0
- package/dist/src/util/publish/publisher-rpc-peer.js.map +1 -0
- package/dist/src/util/telemetry.d.ts +12 -0
- package/dist/src/util/telemetry.d.ts.map +1 -0
- package/dist/src/util/telemetry.js +73 -0
- package/dist/src/util/telemetry.js.map +1 -0
- package/dist/src/util/telemetryrc.json +6 -0
- package/dist/src/util/util.d.ts +10 -0
- package/dist/src/util/util.d.ts.map +1 -0
- package/dist/src/util/util.js +74 -0
- package/dist/src/util/util.js.map +1 -0
- package/oclif.manifest.json +1 -0
- package/package.json +97 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//
|
|
3
|
+
// Copyright 2022 DXOS.org
|
|
4
|
+
//
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./telemetry"), exports);
|
|
21
|
+
__exportStar(require("./publish"), exports);
|
|
22
|
+
__exportStar(require("./util"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/util/index.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;;;;;AAEF,8CAA4B;AAC5B,4CAA0B;AAC1B,yCAAuB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PackageModule, Logger } from './common';
|
|
2
|
+
export interface BuildParams {
|
|
3
|
+
log: Logger;
|
|
4
|
+
module: PackageModule;
|
|
5
|
+
}
|
|
6
|
+
interface BuildArgs {
|
|
7
|
+
verbose?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const build: ({ verbose }: BuildArgs, { log, module }: BuildParams) => void;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../../src/util/publish/build.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEtD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,aAAa,CAAC;CACvB;AAED,UAAU,SAAS;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,KAAK,gBAAiB,SAAS,mBAAmB,WAAW,SAoBzE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//
|
|
3
|
+
// Copyright 2022 DXOS.org
|
|
4
|
+
//
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.build = void 0;
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const build = ({ verbose }, { log, module }) => {
|
|
9
|
+
verbose && log(`Building module ${module.name}...`);
|
|
10
|
+
const [command, ...args] = module.build.command.split(' ');
|
|
11
|
+
// Build with configuration.
|
|
12
|
+
const { status } = (0, child_process_1.spawnSync)(command, args, {
|
|
13
|
+
env: {
|
|
14
|
+
...process.env,
|
|
15
|
+
CONFIG_DYNAMIC: 'true'
|
|
16
|
+
},
|
|
17
|
+
stdio: verbose ? 'inherit' : undefined
|
|
18
|
+
});
|
|
19
|
+
if (status) {
|
|
20
|
+
verbose && log('Build failed.');
|
|
21
|
+
process.exit(status);
|
|
22
|
+
}
|
|
23
|
+
verbose && log('Build succeded.');
|
|
24
|
+
};
|
|
25
|
+
exports.build = build;
|
|
26
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../src/util/publish/build.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;AAEF,iDAA0C;AAanC,MAAM,KAAK,GAAG,CAAC,EAAE,OAAO,EAAa,EAAE,EAAE,GAAG,EAAE,MAAM,EAAe,EAAE,EAAE;IAC5E,OAAO,IAAI,GAAG,CAAC,mBAAmB,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC;IAEpD,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,KAAM,CAAC,OAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE7D,4BAA4B;IAC5B,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,yBAAS,EAAC,OAAO,EAAE,IAAI,EAAE;QAC1C,GAAG,EAAE;YACH,GAAG,OAAO,CAAC,GAAG;YACd,cAAc,EAAE,MAAM;SACvB;QACD,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;KACvC,CAAC,CAAC;IAEH,IAAI,MAAM,EAAE;QACV,OAAO,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC;QAChC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KACtB;IAED,OAAO,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC;AACpC,CAAC,CAAC;AApBW,QAAA,KAAK,SAoBhB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ConfigProto } from '@dxos/config';
|
|
2
|
+
export declare type PackageModule = NonNullable<NonNullable<ConfigProto['package']>['modules']>[0];
|
|
3
|
+
export declare type PackageRepo = NonNullable<NonNullable<ConfigProto['package']>['repos']>[0];
|
|
4
|
+
export declare type Logger = (message?: string, ...args: any[]) => void;
|
|
5
|
+
export declare const mapModules: (modules: PackageModule[]) => {
|
|
6
|
+
key: string | undefined;
|
|
7
|
+
bundle: string;
|
|
8
|
+
}[];
|
|
9
|
+
export declare const printModules: (modules: PackageModule[], flags?: {}) => void;
|
|
10
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/util/publish/common.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,oBAAY,aAAa,GAAG,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3F,oBAAY,WAAW,GAAG,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvF,oBAAY,MAAM,GAAG,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;AAEhE,eAAO,MAAM,UAAU,YAAa,aAAa,EAAE;;;GAKlD,CAAC;AAEF,eAAO,MAAM,YAAY,YAAa,aAAa,EAAE,qBAepD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//
|
|
3
|
+
// Copyright 2022 DXOS.org
|
|
4
|
+
//
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.printModules = exports.mapModules = void 0;
|
|
7
|
+
const core_1 = require("@oclif/core");
|
|
8
|
+
const ipfs_http_client_1 = require("ipfs-http-client");
|
|
9
|
+
const mapModules = (modules) => {
|
|
10
|
+
return modules.map((mod) => ({
|
|
11
|
+
key: mod.name,
|
|
12
|
+
bundle: ipfs_http_client_1.CID.decode(mod.bundle).toString()
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
exports.mapModules = mapModules;
|
|
16
|
+
const printModules = (modules, flags = {}) => {
|
|
17
|
+
core_1.CliUx.ux.table((0, exports.mapModules)(modules), {
|
|
18
|
+
key: {
|
|
19
|
+
header: 'Name'
|
|
20
|
+
},
|
|
21
|
+
bundle: {
|
|
22
|
+
header: 'Bundle'
|
|
23
|
+
}
|
|
24
|
+
}, {
|
|
25
|
+
...flags
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
exports.printModules = printModules;
|
|
29
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../src/util/publish/common.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;AAEF,sCAAoC;AACpC,uDAAuC;AAQhC,MAAM,UAAU,GAAG,CAAC,OAAwB,EAAE,EAAE;IACrD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAC3B,GAAG,EAAE,GAAG,CAAC,IAAI;QACb,MAAM,EAAE,sBAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAO,CAAC,CAAC,QAAQ,EAAE;KAC3C,CAAC,CAAC,CAAC;AACN,CAAC,CAAC;AALW,QAAA,UAAU,cAKrB;AAEK,MAAM,YAAY,GAAG,CAAC,OAAwB,EAAE,KAAK,GAAG,EAAE,EAAE,EAAE;IACnE,YAAK,CAAC,EAAE,CAAC,KAAK,CACZ,IAAA,kBAAU,EAAC,OAAO,CAAC,EACnB;QACE,GAAG,EAAE;YACH,MAAM,EAAE,MAAM;SACf;QACD,MAAM,EAAE;YACN,MAAM,EAAE,QAAQ;SACjB;KACF,EACD;QACE,GAAG,KAAK;KACT,CACF,CAAC;AACJ,CAAC,CAAC;AAfW,QAAA,YAAY,gBAevB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/util/publish/config.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAQtC,eAAO,MAAM,UAAU,gBAAsB,MAAM,KAA+B,QAAQ,MAAM,CAoB/F,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//
|
|
3
|
+
// Copyright 2022 DXOS.org
|
|
4
|
+
//
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.loadConfig = void 0;
|
|
10
|
+
const assert_1 = __importDefault(require("assert"));
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
13
|
+
const lodash_defaultsdeep_1 = __importDefault(require("lodash.defaultsdeep"));
|
|
14
|
+
const path_1 = __importDefault(require("path"));
|
|
15
|
+
const config_1 = require("@dxos/config");
|
|
16
|
+
const DEFAULT_BUILD_COMMAND = 'npm run build';
|
|
17
|
+
const EXTENSION_CONFIG_FILENAME = 'dx.yml';
|
|
18
|
+
const loadConfig = async (configPath = EXTENSION_CONFIG_FILENAME) => {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
const absolute = path_1.default.isAbsolute(configPath);
|
|
21
|
+
configPath = absolute ? configPath : path_1.default.join(process.cwd(), configPath);
|
|
22
|
+
(0, assert_1.default)(fs_1.default.existsSync(configPath), `"${configPath}" not found.`);
|
|
23
|
+
const dxConfig = js_yaml_1.default.load(String(fs_1.default.readFileSync(configPath)));
|
|
24
|
+
(0, assert_1.default)((_b = (_a = dxConfig.package) === null || _a === void 0 ? void 0 : _a.modules) === null || _b === void 0 ? void 0 : _b.length, `No modules found in ${configPath}`);
|
|
25
|
+
return new config_1.Config({
|
|
26
|
+
version: 1,
|
|
27
|
+
package: {
|
|
28
|
+
modules: dxConfig.package.modules.map((module) => (0, lodash_defaultsdeep_1.default)(module, {
|
|
29
|
+
build: { command: DEFAULT_BUILD_COMMAND }
|
|
30
|
+
}))
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
exports.loadConfig = loadConfig;
|
|
35
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/util/publish/config.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;AAEF,oDAA4B;AAC5B,4CAAoB;AACpB,sDAA2B;AAC3B,8EAA+C;AAC/C,gDAAwB;AAExB,yCAAsC;AAKtC,MAAM,qBAAqB,GAAG,eAAe,CAAC;AAC9C,MAAM,yBAAyB,GAAG,QAAQ,CAAC;AAEpC,MAAM,UAAU,GAAG,KAAK,EAAE,aAAqB,yBAAyB,EAAmB,EAAE;;IAClG,MAAM,QAAQ,GAAG,cAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC7C,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;IAE1E,IAAA,gBAAM,EAAC,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,IAAI,UAAU,cAAc,CAAC,CAAC;IAEhE,MAAM,QAAQ,GAAG,iBAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAE,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAgB,CAAC;IAE/E,IAAA,gBAAM,EAAC,MAAA,MAAA,QAAQ,CAAC,OAAO,0CAAE,OAAO,0CAAE,MAAM,EAAE,uBAAuB,UAAU,EAAE,CAAC,CAAC;IAE/E,OAAO,IAAI,eAAM,CAAC;QAChB,OAAO,EAAE,CAAC;QACV,OAAO,EAAE;YACP,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAqB,EAAE,EAAE,CAC9D,IAAA,6BAAY,EAAC,MAAM,EAAE;gBACnB,KAAK,EAAE,EAAE,OAAO,EAAE,qBAAqB,EAAE;aAC1C,CAAC,CACH;SACF;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AApBW,QAAA,UAAU,cAoBrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/util/publish/index.ts"],"names":[],"mappings":"AAIA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//
|
|
3
|
+
// Copyright 2022 DXOS.org
|
|
4
|
+
//
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./build"), exports);
|
|
21
|
+
__exportStar(require("./common"), exports);
|
|
22
|
+
__exportStar(require("./config"), exports);
|
|
23
|
+
__exportStar(require("./ipfs-upload"), exports);
|
|
24
|
+
__exportStar(require("./publish"), exports);
|
|
25
|
+
__exportStar(require("./publisher-rpc-peer"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/util/publish/index.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;;;;;AAEF,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB;AACzB,gDAA8B;AAC9B,4CAA0B;AAC1B,uDAAqC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CID } from 'ipfs-http-client';
|
|
2
|
+
import { ConfigProto } from '@dxos/config';
|
|
3
|
+
interface UploadOptions {
|
|
4
|
+
timeout: string | number;
|
|
5
|
+
progress?: (bytes: number, path?: string) => void;
|
|
6
|
+
pin?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const uploadToIPFS: (path: string, config?: ConfigProto, options?: UploadOptions) => Promise<CID>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=ipfs-upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipfs-upload.d.ts","sourceRoot":"","sources":["../../../../src/util/publish/ipfs-upload.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,GAAG,EAAsB,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,UAAU,aAAa;IACrB,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,eAAO,MAAM,YAAY,SAAgB,MAAM,WAAW,WAAW,YAAY,aAAa,KAAG,QAAQ,GAAG,CA6B3G,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//
|
|
3
|
+
// Copyright 2022 DXOS.org
|
|
4
|
+
//
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.uploadToIPFS = void 0;
|
|
10
|
+
const assert_1 = __importDefault(require("assert"));
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
const ipfs_http_client_1 = require("ipfs-http-client");
|
|
13
|
+
const uploadToIPFS = async (path, config, options) => {
|
|
14
|
+
var _a, _b, _c;
|
|
15
|
+
const { timeout, pin = true, progress } = options || {};
|
|
16
|
+
const ipfsServer = (_c = (_b = (_a = config === null || config === void 0 ? void 0 : config.runtime) === null || _a === void 0 ? void 0 : _a.services) === null || _b === void 0 ? void 0 : _b.ipfs) === null || _c === void 0 ? void 0 : _c.server;
|
|
17
|
+
(0, assert_1.default)(ipfsServer, 'Invalid IPFS Server.');
|
|
18
|
+
const ipfsClient = (0, ipfs_http_client_1.create)({
|
|
19
|
+
url: ipfsServer,
|
|
20
|
+
timeout: timeout || '1m'
|
|
21
|
+
});
|
|
22
|
+
if (!fs_1.default.existsSync(path)) {
|
|
23
|
+
throw new Error('Incorrect path to definitons. File or directory does not exist');
|
|
24
|
+
}
|
|
25
|
+
if (fs_1.default.lstatSync(path).isDirectory()) {
|
|
26
|
+
const files = [];
|
|
27
|
+
for await (const file of ipfsClient.addAll((0, ipfs_http_client_1.globSource)(path, '**/*'), {
|
|
28
|
+
progress,
|
|
29
|
+
pin,
|
|
30
|
+
wrapWithDirectory: true
|
|
31
|
+
})) {
|
|
32
|
+
files.push(file);
|
|
33
|
+
}
|
|
34
|
+
return files[files.length - 1].cid;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const content = fs_1.default.readFileSync(path);
|
|
38
|
+
const addResult = await ipfsClient.add(content, { pin });
|
|
39
|
+
return addResult.cid;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports.uploadToIPFS = uploadToIPFS;
|
|
43
|
+
//# sourceMappingURL=ipfs-upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipfs-upload.js","sourceRoot":"","sources":["../../../../src/util/publish/ipfs-upload.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;AAEF,oDAA4B;AAC5B,4CAAoB;AACpB,uDAA2D;AAUpD,MAAM,YAAY,GAAG,KAAK,EAAE,IAAY,EAAE,MAAoB,EAAE,OAAuB,EAAgB,EAAE;;IAC9G,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAExD,MAAM,UAAU,GAAG,MAAA,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,0CAAE,QAAQ,0CAAE,IAAI,0CAAE,MAAM,CAAC;IAC3D,IAAA,gBAAM,EAAC,UAAU,EAAE,sBAAsB,CAAC,CAAC;IAE3C,MAAM,UAAU,GAAG,IAAA,yBAAM,EAAC;QACxB,GAAG,EAAE,UAAU;QACf,OAAO,EAAE,OAAO,IAAI,IAAI;KACzB,CAAC,CAAC;IAEH,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;KACnF;IACD,IAAI,YAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;QACpC,MAAM,KAAK,GAAG,EAAE,CAAC;QACjB,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,UAAU,CAAC,MAAM,CAAC,IAAA,6BAAU,EAAC,IAAI,EAAE,MAAM,CAAC,EAAE;YACnE,QAAQ;YACR,GAAG;YACH,iBAAiB,EAAE,IAAI;SACxB,CAAC,EAAE;YACF,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAClB;QACD,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;KACpC;SAAM;QACL,MAAM,OAAO,GAAG,YAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACtC,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QACzD,OAAO,SAAS,CAAC,GAAG,CAAC;KACtB;AACH,CAAC,CAAC;AA7BW,QAAA,YAAY,gBA6BvB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ConfigProto } from '@dxos/config';
|
|
2
|
+
import { PackageModule } from './common';
|
|
3
|
+
export interface PublishParams {
|
|
4
|
+
config?: ConfigProto;
|
|
5
|
+
module: PackageModule;
|
|
6
|
+
}
|
|
7
|
+
interface PublishArgs {
|
|
8
|
+
verbose?: boolean;
|
|
9
|
+
pin?: boolean;
|
|
10
|
+
timeout?: string | number;
|
|
11
|
+
path?: string;
|
|
12
|
+
config?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const publish: ({ verbose, timeout, path, pin }: PublishArgs, { config, module }: PublishParams) => Promise<import("ipfs-http-client").CID>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=publish.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../../src/util/publish/publish.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAczC,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,aAAa,CAAC;CACvB;AAED,UAAU,WAAW;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,OAAO,oCAA2C,WAAW,sBAAsB,aAAa,4CAwB5G,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//
|
|
3
|
+
// Copyright 2022 DXOS.org
|
|
4
|
+
//
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.publish = void 0;
|
|
10
|
+
const assert_1 = __importDefault(require("assert"));
|
|
11
|
+
const cli_progress_1 = __importDefault(require("cli-progress"));
|
|
12
|
+
const fs_1 = __importDefault(require("fs"));
|
|
13
|
+
const get_folder_size_1 = __importDefault(require("get-folder-size"));
|
|
14
|
+
const path_1 = require("path");
|
|
15
|
+
const util_1 = require("util");
|
|
16
|
+
const debug_1 = require("@dxos/debug");
|
|
17
|
+
const ipfs_upload_1 = require("./ipfs-upload");
|
|
18
|
+
const DEFAULT_OUTDIR = 'out';
|
|
19
|
+
const getFolderSize = (0, util_1.promisify)(get_folder_size_1.default);
|
|
20
|
+
/**
|
|
21
|
+
* Encodes DXN string to fs path.
|
|
22
|
+
*
|
|
23
|
+
* Example: `example:app/braneframe` => `example/app/braneframe`
|
|
24
|
+
*/
|
|
25
|
+
const encodeName = (name) => name.replaceAll(':', '/');
|
|
26
|
+
const publish = async ({ verbose, timeout, path, pin }, { config, module }) => {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
(0, assert_1.default)(module.name, 'Module name is required to publish.');
|
|
29
|
+
verbose && (0, debug_1.log)(`Publishing ${module.name}...`);
|
|
30
|
+
const moduleOut = `out/${encodeName(module.name)}`;
|
|
31
|
+
const outdir = (_b = path !== null && path !== void 0 ? path : (_a = module.build) === null || _a === void 0 ? void 0 : _a.outdir) !== null && _b !== void 0 ? _b : (fs_1.default.existsSync(moduleOut) ? moduleOut : DEFAULT_OUTDIR);
|
|
32
|
+
const publishFolder = (0, path_1.join)(process.cwd(), outdir);
|
|
33
|
+
const total = await getFolderSize(publishFolder);
|
|
34
|
+
const bar = new cli_progress_1.default.SingleBar({}, cli_progress_1.default.Presets.shades_classic);
|
|
35
|
+
verbose && bar.start(total, 0);
|
|
36
|
+
const cid = await (0, ipfs_upload_1.uploadToIPFS)(publishFolder, config, {
|
|
37
|
+
timeout: timeout || '10m',
|
|
38
|
+
pin,
|
|
39
|
+
progress: verbose ? (bytes) => bar.update(bytes) : undefined
|
|
40
|
+
});
|
|
41
|
+
verbose && bar.update(total);
|
|
42
|
+
verbose && bar.stop();
|
|
43
|
+
verbose && (0, debug_1.log)(`Published ${module.name} to IPFS with cid ${cid.toString()}`);
|
|
44
|
+
return cid;
|
|
45
|
+
};
|
|
46
|
+
exports.publish = publish;
|
|
47
|
+
//# sourceMappingURL=publish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../../../src/util/publish/publish.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;AAEF,oDAA4B;AAC5B,gEAAuC;AACvC,4CAAoB;AACpB,sEAAyC;AACzC,+BAA4B;AAC5B,+BAAiC;AAGjC,uCAAkC;AAGlC,+CAA6C;AAE7C,MAAM,cAAc,GAAG,KAAK,CAAC;AAE7B,MAAM,aAAa,GAAG,IAAA,gBAAS,EAAC,yBAAU,CAAC,CAAC;AAE5C;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU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IAEH,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;IAEtB,OAAO,IAAI,IAAA,WAAG,EAAC,aAAa,MAAM,CAAC,IAAI,qBAAqB,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAE9E,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAxBW,QAAA,OAAO,WAwBlB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Event } from '@dxos/async';
|
|
2
|
+
import { Publisher } from '@dxos/protocols/proto/dxos/service/publisher';
|
|
3
|
+
export declare class PublisherRpcPeer {
|
|
4
|
+
private readonly _url;
|
|
5
|
+
private readonly _socket;
|
|
6
|
+
private readonly _rpc;
|
|
7
|
+
private readonly _connectTrigger;
|
|
8
|
+
readonly connected: Event<void>;
|
|
9
|
+
readonly disconnected: Event<void>;
|
|
10
|
+
readonly error: Event<Error>;
|
|
11
|
+
constructor(_url: string);
|
|
12
|
+
get rpc(): Publisher;
|
|
13
|
+
close(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=publisher-rpc-peer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publisher-rpc-peer.d.ts","sourceRoot":"","sources":["../../../../src/util/publish/publisher-rpc-peer.ts"],"names":[],"mappings":"AAOA,OAAO,EAAW,KAAK,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,8CAA8C,CAAC;AAKzE,qBAAa,gBAAgB;IASf,OAAO,CAAC,QAAQ,CAAC,IAAI;IARjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAY;IACpC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAyC;IAC9D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiB;IAEjD,QAAQ,CAAC,SAAS,cAAe;IACjC,QAAQ,CAAC,YAAY,cAAe;IACpC,QAAQ,CAAC,KAAK,eAAsB;gBAEP,IAAI,EAAE,MAAM;IAqDzC,IAAI,GAAG,IAAI,SAAS,CAEnB;IAEK,KAAK;CAOZ"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//
|
|
3
|
+
// Copyright 2022 DXOS.org
|
|
4
|
+
//
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.PublisherRpcPeer = void 0;
|
|
10
|
+
const debug_1 = __importDefault(require("debug"));
|
|
11
|
+
const isomorphic_ws_1 = __importDefault(require("isomorphic-ws"));
|
|
12
|
+
const async_1 = require("@dxos/async");
|
|
13
|
+
const protocols_1 = require("@dxos/protocols");
|
|
14
|
+
const rpc_1 = require("@dxos/rpc");
|
|
15
|
+
const log = (0, debug_1.default)('dxos:network-manager:publisher-rpc-peer');
|
|
16
|
+
class PublisherRpcPeer {
|
|
17
|
+
constructor(_url) {
|
|
18
|
+
this._url = _url;
|
|
19
|
+
this._connectTrigger = new async_1.Trigger();
|
|
20
|
+
this.connected = new async_1.Event();
|
|
21
|
+
this.disconnected = new async_1.Event();
|
|
22
|
+
this.error = new async_1.Event();
|
|
23
|
+
this._socket = new isomorphic_ws_1.default(this._url);
|
|
24
|
+
this._socket.onopen = async () => {
|
|
25
|
+
try {
|
|
26
|
+
await this._rpc.open();
|
|
27
|
+
log(`RPC open ${this._url}`);
|
|
28
|
+
this.connected.emit();
|
|
29
|
+
this._connectTrigger.wake();
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
this.error.emit(err);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
this._socket.onclose = async () => {
|
|
36
|
+
log(`Disconnected ${this._url}`);
|
|
37
|
+
this.disconnected.emit();
|
|
38
|
+
try {
|
|
39
|
+
await this._rpc.close();
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
this.error.emit(err);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
this._socket.onerror = (event) => {
|
|
46
|
+
var _a;
|
|
47
|
+
log(`Publisher socket error ${this._url} ${event.message}`);
|
|
48
|
+
this.error.emit((_a = event.error) !== null && _a !== void 0 ? _a : new Error(event.message));
|
|
49
|
+
};
|
|
50
|
+
this._rpc = (0, rpc_1.createProtoRpcPeer)({
|
|
51
|
+
requested: {
|
|
52
|
+
Publisher: protocols_1.schema.getService('dxos.service.publisher.Publisher')
|
|
53
|
+
},
|
|
54
|
+
exposed: {},
|
|
55
|
+
handlers: {},
|
|
56
|
+
noHandshake: true,
|
|
57
|
+
timeout: 1000000,
|
|
58
|
+
port: {
|
|
59
|
+
send: (msg) => {
|
|
60
|
+
this._socket.send(msg);
|
|
61
|
+
},
|
|
62
|
+
subscribe: (cb) => {
|
|
63
|
+
this._socket.onmessage = async (msg) => {
|
|
64
|
+
if (typeof Blob !== 'undefined' && msg.data instanceof Blob) {
|
|
65
|
+
cb(Buffer.from(await msg.data.arrayBuffer()));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
cb(msg.data);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
get rpc() {
|
|
76
|
+
return this._rpc.rpc.Publisher;
|
|
77
|
+
}
|
|
78
|
+
async close() {
|
|
79
|
+
try {
|
|
80
|
+
await this._rpc.close();
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
this._socket.close();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.PublisherRpcPeer = PublisherRpcPeer;
|
|
88
|
+
//# sourceMappingURL=publisher-rpc-peer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publisher-rpc-peer.js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,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI;YACF,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;SACzB;gBAAS;YACR,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;SACtB;IACH,CAAC;CACF;AAzED,4CAyEC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const DX_ENVIRONMENT: string;
|
|
2
|
+
export declare const DX_RELEASE: undefined;
|
|
3
|
+
export declare const SENTRY_DESTINATION: undefined;
|
|
4
|
+
export declare const TELEMETRY_API_KEY: undefined;
|
|
5
|
+
export declare type TelemetryContext = {
|
|
6
|
+
installationId: string;
|
|
7
|
+
isInternalUser: boolean;
|
|
8
|
+
fullCrashReports: boolean;
|
|
9
|
+
disableTelemetry: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const getTelemetryContext: (configDir: string) => Promise<TelemetryContext>;
|
|
12
|
+
//# sourceMappingURL=telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../../src/util/telemetry.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,cAAc,QAA0C,CAAC;AACtE,eAAO,MAAM,UAAU,WAAsC,CAAC;AAC9D,eAAO,MAAM,kBAAkB,WAA8C,CAAC;AAC9E,eAAO,MAAM,iBAAiB,WAA6C,CAAC;AAE5E,oBAAY,gBAAgB,GAAG;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAQF,eAAO,MAAM,mBAAmB,cAAqB,MAAM,KAAG,QAAQ,gBAAgB,CAarF,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//
|
|
3
|
+
// Copyright 2022 DXOS.org
|
|
4
|
+
//
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
var _a, _b, _c, _d;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.getTelemetryContext = exports.TELEMETRY_API_KEY = exports.SENTRY_DESTINATION = exports.DX_RELEASE = exports.DX_ENVIRONMENT = void 0;
|
|
11
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
12
|
+
const promises_1 = require("node:fs/promises");
|
|
13
|
+
const node_path_1 = require("node:path");
|
|
14
|
+
const uuid_1 = require("uuid");
|
|
15
|
+
const sentry_1 = require("@dxos/sentry");
|
|
16
|
+
const telemetryrc_json_1 = __importDefault(require("./telemetryrc.json"));
|
|
17
|
+
exports.DX_ENVIRONMENT = (_a = telemetryrc_json_1.default.DX_ENVIRONMENT) !== null && _a !== void 0 ? _a : undefined;
|
|
18
|
+
exports.DX_RELEASE = (_b = telemetryrc_json_1.default.DX_RELEASE) !== null && _b !== void 0 ? _b : undefined;
|
|
19
|
+
exports.SENTRY_DESTINATION = (_c = telemetryrc_json_1.default.SENTRY_DESTINATION) !== null && _c !== void 0 ? _c : undefined;
|
|
20
|
+
exports.TELEMETRY_API_KEY = (_d = telemetryrc_json_1.default.TELEMETRY_API_KEY) !== null && _d !== void 0 ? _d : undefined;
|
|
21
|
+
const DEFAULTS = {
|
|
22
|
+
isInternalUser: false,
|
|
23
|
+
fullCrashReports: false,
|
|
24
|
+
disableTelemetry: false
|
|
25
|
+
};
|
|
26
|
+
const getTelemetryContext = async (configDir) => {
|
|
27
|
+
var _a;
|
|
28
|
+
const configDirExists = await exists(configDir);
|
|
29
|
+
if (!configDirExists) {
|
|
30
|
+
await (0, promises_1.mkdir)(configDir, { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
const idPath = (0, node_path_1.join)(configDir, 'telemetry.yml');
|
|
33
|
+
if (await exists(idPath)) {
|
|
34
|
+
const context = await (0, promises_1.readFile)(idPath, 'utf-8');
|
|
35
|
+
return (_a = validate(context)) !== null && _a !== void 0 ? _a : createContext(idPath);
|
|
36
|
+
}
|
|
37
|
+
return createContext(idPath);
|
|
38
|
+
};
|
|
39
|
+
exports.getTelemetryContext = getTelemetryContext;
|
|
40
|
+
const createContext = async (idPath) => {
|
|
41
|
+
const installationId = (0, uuid_1.v4)();
|
|
42
|
+
const context = js_yaml_1.default.dump({ installationId });
|
|
43
|
+
const comment = '# This file is automatically generated by the @dxos/cli.\n';
|
|
44
|
+
await (0, promises_1.writeFile)(idPath, `${comment}${context}`, 'utf-8');
|
|
45
|
+
return { ...DEFAULTS, installationId };
|
|
46
|
+
};
|
|
47
|
+
const validate = (contextString) => {
|
|
48
|
+
try {
|
|
49
|
+
const context = js_yaml_1.default.load(contextString);
|
|
50
|
+
if (Boolean(context.installationId) && (0, uuid_1.validate)(context.installationId)) {
|
|
51
|
+
return { ...DEFAULTS, ...context };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
(0, sentry_1.captureException)(err);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
// TODO(wittjosiah): Factor out.
|
|
59
|
+
const exists = async (filePath) => {
|
|
60
|
+
try {
|
|
61
|
+
const result = await (0, promises_1.stat)(filePath);
|
|
62
|
+
return !!result;
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
if (/ENOENT/.test(err.message)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw err;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=telemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../../src/util/telemetry.ts"],"names":[],"mappings":";AAAA,EAAE;AAC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GAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,iBAAI,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,4DAA4D,CAAC;IAC7E,MAAM,IAAA,oBAAS,EAAC,MAAM,EAAE,GAAG,OAAO,GAAG,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;IACzD,OAAO,EAAE,GAAG,QAAQ,EAAE,cAAc,EAAE,CAAC;AACzC,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,aAAqB,EAAE,EAAE;IACzC,IAAI;QACF,MAAM,OAAO,GAAG,iBAAI,CAAC,IAAI,CAAC,aAAa,CAAqB,CAAC;QAC7D,IAAI,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,IAAA,eAAY,EAAC,OAAO,CAAC,cAAc,CAAC,EAAE;YAC3E,OAAO,EAAE,GAAG,QAAQ,EAAE,GAAG,OAAO,EAAE,CAAC;SACpC;KACF;IAAC,OAAO,GAAQ,EAAE;QACjB,IAAA,yBAAgB,EAAC,GAAG,CAAC,CAAC;KACvB;AACH,CAAC,CAAC;AAEF,gCAAgC;AAChC,MAAM,MAAM,GAAG,KAAK,EAAE,QAAgB,EAAoB,EAAE;IAC1D,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,IAAA,eAAI,EAAC,QAAQ,CAAC,CAAC;QACpC,OAAO,CAAC,CAAC,MAAM,CAAC;KACjB;IAAC,OAAO,GAAQ,EAAE;QACjB,IAAI,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YAC9B,OAAO,KAAK,CAAC;SACd;aAAM;YACL,MAAM,GAAG,CAAC;SACX;KACF;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Party } from '@dxos/client';
|
|
2
|
+
export declare const selectSpace: (parties: Party[]) => Promise<any>;
|
|
3
|
+
export declare const mapSpaces: (parties: Party[], truncateKeys?: boolean) => {
|
|
4
|
+
key: string;
|
|
5
|
+
name: any;
|
|
6
|
+
}[];
|
|
7
|
+
export declare const printSpaces: (parties: Party[], flags?: {}) => void;
|
|
8
|
+
export declare const mapMembers: (members: any, truncateKeys?: boolean) => any;
|
|
9
|
+
export declare const printMembers: (members: any, flags?: {}) => void;
|
|
10
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util/util.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAUrC,eAAO,MAAM,WAAW,YAAmB,KAAK,EAAE,iBAgBjD,CAAC;AAEF,eAAO,MAAM,SAAS,YAAa,KAAK,EAAE;;;GAKzC,CAAC;AAEF,eAAO,MAAM,WAAW,YAAa,KAAK,EAAE,qBAe3C,CAAC;AAOF,eAAO,MAAM,UAAU,YAAa,GAAG,gCAKtC,CAAC;AAEF,eAAO,MAAM,YAAY,YAAa,GAAG,qBAexC,CAAC"}
|