@hailer/app-sdk 1.0.3 → 2.0.0-beta-2
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/lib/app-sdk.js +2 -1
- package/lib/app-sdk.js.map +4 -4
- package/lib/constants.d.ts +0 -1
- package/lib/constants.js +3 -0
- package/lib/hailer-api.d.ts +4 -20
- package/lib/hailer-api.js +147 -0
- package/lib/{src/index.d.ts → index.js} +1 -0
- package/lib/modules/activity/kanban.js +88 -0
- package/lib/modules/activity.d.ts +6 -19
- package/lib/modules/activity.js +170 -0
- package/lib/modules/app.d.ts +4 -2
- package/lib/modules/insight.d.ts +0 -1
- package/lib/modules/insight.js +73 -0
- package/lib/modules/network.js +74 -0
- package/lib/modules/permission.d.ts +2 -1
- package/lib/modules/process.js +104 -0
- package/lib/modules/public/app.d.ts +2 -2
- package/lib/modules/public/form.js +117 -0
- package/lib/modules/public/insight.js +114 -0
- package/lib/modules/team.d.ts +17 -0
- package/lib/modules/ui/activity.js +72 -0
- package/lib/modules/ui.js +10 -0
- package/lib/modules/user.d.ts +1 -3
- package/lib/modules/user.js +133 -0
- package/lib/modules/workflow.d.ts +14 -2
- package/lib/public-api.d.ts +16 -0
- package/lib/public-api.js +13 -0
- package/lib/tools/minimal-password-prompt.d.ts +1 -0
- package/lib/tools/minimal-password-prompt.js +50 -0
- package/lib/tools/publish.cjs +121 -125
- package/lib/tools/replace-private.d.ts +1 -0
- package/lib/tools/replace-private.js +33 -0
- package/lib/types.d.ts +131 -42
- package/lib/types.js +28 -0
- package/package.json +2 -3
- package/lib/modules/product-installed.d.ts +0 -40
- package/lib/modules/product-version.d.ts +0 -38
- package/lib/modules/public/product-version.d.ts +0 -16
- package/lib/modules/public/version.d.ts +0 -16
- package/lib/modules/version.d.ts +0 -16
- package/lib/src/constants.d.ts +0 -7
- package/lib/src/hailer-api.d.ts +0 -92
- package/lib/src/modules/activity/kanban.d.ts +0 -36
- package/lib/src/modules/activity.d.ts +0 -83
- package/lib/src/modules/app.d.ts +0 -12
- package/lib/src/modules/insight.d.ts +0 -36
- package/lib/src/modules/network.d.ts +0 -14
- package/lib/src/modules/permission.d.ts +0 -9
- package/lib/src/modules/process.d.ts +0 -38
- package/lib/src/modules/product-installed.d.ts +0 -40
- package/lib/src/modules/product-version.d.ts +0 -16
- package/lib/src/modules/product.d.ts +0 -104
- package/lib/src/modules/public/app.d.ts +0 -17
- package/lib/src/modules/public/form.d.ts +0 -31
- package/lib/src/modules/public/insight.d.ts +0 -30
- package/lib/src/modules/public/product-version.d.ts +0 -16
- package/lib/src/modules/public/product.d.ts +0 -27
- package/lib/src/modules/public.d.ts +0 -22
- package/lib/src/modules/ui/activity.d.ts +0 -30
- package/lib/src/modules/ui/files.d.ts +0 -18
- package/lib/src/modules/ui/snackbar.d.ts +0 -18
- package/lib/src/modules/ui.d.ts +0 -17
- package/lib/src/modules/user.d.ts +0 -36
- package/lib/src/modules/workflow.d.ts +0 -24
- package/lib/src/types.d.ts +0 -381
- package/lib/version.d.ts +0 -0
|
@@ -0,0 +1,133 @@
|
|
|
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 __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { HailerError } from '../types';
|
|
38
|
+
var User = /** @class */ (function () {
|
|
39
|
+
function User(client, apiVersion) {
|
|
40
|
+
this.client = client;
|
|
41
|
+
this.apiVersion = apiVersion;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns the specified user
|
|
45
|
+
*
|
|
46
|
+
* @param userId id of the Hailer user
|
|
47
|
+
* @param options object containing apiVersion option
|
|
48
|
+
*
|
|
49
|
+
* @returns Hailer user information
|
|
50
|
+
*
|
|
51
|
+
* @throws {HailerError} if request is incorrect
|
|
52
|
+
*/
|
|
53
|
+
User.prototype.get = function (userId, options) {
|
|
54
|
+
var _a;
|
|
55
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
+
var res, error_1;
|
|
57
|
+
return __generator(this, function (_b) {
|
|
58
|
+
switch (_b.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
_b.trys.push([0, 2, , 3]);
|
|
61
|
+
return [4 /*yield*/, this.client.requestAsync("v".concat((_a = options === null || options === void 0 ? void 0 : options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion, ".user.get"), [userId])];
|
|
62
|
+
case 1:
|
|
63
|
+
res = _b.sent();
|
|
64
|
+
return [2 /*return*/, res];
|
|
65
|
+
case 2:
|
|
66
|
+
error_1 = _b.sent();
|
|
67
|
+
throw new HailerError(error_1);
|
|
68
|
+
case 3: return [2 /*return*/];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Returns the current user
|
|
75
|
+
*
|
|
76
|
+
* @param options object containing apiVersion option
|
|
77
|
+
*
|
|
78
|
+
* @returns the current Hailer user information
|
|
79
|
+
*
|
|
80
|
+
* @throws {HailerError} if request is incorrect
|
|
81
|
+
*/
|
|
82
|
+
User.prototype.current = function (options) {
|
|
83
|
+
var _a;
|
|
84
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
+
var res, error_2;
|
|
86
|
+
return __generator(this, function (_b) {
|
|
87
|
+
switch (_b.label) {
|
|
88
|
+
case 0:
|
|
89
|
+
_b.trys.push([0, 2, , 3]);
|
|
90
|
+
return [4 /*yield*/, this.client.requestAsync("v".concat((_a = options === null || options === void 0 ? void 0 : options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion, ".user.current"), [])];
|
|
91
|
+
case 1:
|
|
92
|
+
res = _b.sent();
|
|
93
|
+
return [2 /*return*/, res];
|
|
94
|
+
case 2:
|
|
95
|
+
error_2 = _b.sent();
|
|
96
|
+
throw new HailerError(error_2);
|
|
97
|
+
case 3: return [2 /*return*/];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Lists all Hailer users from a workspace
|
|
104
|
+
*
|
|
105
|
+
* @param options object containing apiVersion option
|
|
106
|
+
*
|
|
107
|
+
* @returns list of Hailer users in the workspace the app user is currently in
|
|
108
|
+
*
|
|
109
|
+
* @throws {HailerError} if request is incorrect
|
|
110
|
+
*/
|
|
111
|
+
User.prototype.list = function (options) {
|
|
112
|
+
var _a;
|
|
113
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
+
var users, error_3;
|
|
115
|
+
return __generator(this, function (_b) {
|
|
116
|
+
switch (_b.label) {
|
|
117
|
+
case 0:
|
|
118
|
+
_b.trys.push([0, 2, , 3]);
|
|
119
|
+
return [4 /*yield*/, this.client.requestAsync("v".concat((_a = options === null || options === void 0 ? void 0 : options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion, ".user.list"), [])];
|
|
120
|
+
case 1:
|
|
121
|
+
users = _b.sent();
|
|
122
|
+
return [2 /*return*/, users];
|
|
123
|
+
case 2:
|
|
124
|
+
error_3 = _b.sent();
|
|
125
|
+
throw new HailerError(error_3);
|
|
126
|
+
case 3: return [2 /*return*/];
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
return User;
|
|
132
|
+
}());
|
|
133
|
+
export { User };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Client } from '@wishcore/wish-rpc';
|
|
2
|
-
import { Workflow } from '../types';
|
|
2
|
+
import { IdsMap, Workflow } from '../types';
|
|
3
3
|
export declare class WorkflowApi {
|
|
4
4
|
private client;
|
|
5
5
|
constructor(client: Client);
|
|
@@ -11,6 +11,16 @@ export declare class WorkflowApi {
|
|
|
11
11
|
* @throws {HailerError} if request is incorrect
|
|
12
12
|
*/
|
|
13
13
|
list(): Promise<Workflow[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Gets a single process from a workspace
|
|
16
|
+
*
|
|
17
|
+
* @param workflowId the id of the process in question
|
|
18
|
+
*
|
|
19
|
+
* @returns the specified Hailer process
|
|
20
|
+
*
|
|
21
|
+
* @throws {HailerError} if request is incorrect
|
|
22
|
+
*/
|
|
23
|
+
get(workflowId: string): Promise<Workflow>;
|
|
14
24
|
/**
|
|
15
25
|
* Gets a single process from a workspace
|
|
16
26
|
*
|
|
@@ -20,5 +30,7 @@ export declare class WorkflowApi {
|
|
|
20
30
|
*
|
|
21
31
|
* @throws {HailerError} if request is incorrect
|
|
22
32
|
*/
|
|
23
|
-
|
|
33
|
+
install(workflowSpec: any, option?: {
|
|
34
|
+
workspaceId?: string;
|
|
35
|
+
}): Promise<IdsMap>;
|
|
24
36
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Form } from './modules/public/form';
|
|
2
|
+
import { Insight } from './modules/public/insight';
|
|
3
|
+
export declare class HailerApiPublic {
|
|
4
|
+
/**
|
|
5
|
+
* Allows accessing public insight methods. Used for reading data from Hailer when app is outside of Hailer
|
|
6
|
+
*/
|
|
7
|
+
insight: Insight;
|
|
8
|
+
/**
|
|
9
|
+
* Allows accessing public forms methods. Used for sending data to Hailer when app is ran outside of Hailer
|
|
10
|
+
*/
|
|
11
|
+
form: Form;
|
|
12
|
+
/**
|
|
13
|
+
* This class is used to access Hailer public API when the app is outside of Hailer
|
|
14
|
+
*/
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Form } from './modules/public/form';
|
|
2
|
+
import { Insight } from './modules/public/insight';
|
|
3
|
+
var HailerApiPublic = /** @class */ (function () {
|
|
4
|
+
/**
|
|
5
|
+
* This class is used to access Hailer public API when the app is outside of Hailer
|
|
6
|
+
*/
|
|
7
|
+
function HailerApiPublic() {
|
|
8
|
+
this.insight = new Insight();
|
|
9
|
+
this.form = new Form();
|
|
10
|
+
}
|
|
11
|
+
return HailerApiPublic;
|
|
12
|
+
}());
|
|
13
|
+
export { HailerApiPublic };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const prompt: (question: string, ctrlcExits?: boolean) => Promise<string>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Re-written to TypeScript to fix typing issue, see: https://www.npmjs.com/package/minimal-password-prompt/v/1.1.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.prompt = void 0;
|
|
5
|
+
const stdin = process.stdin;
|
|
6
|
+
const stdout = process.stdout;
|
|
7
|
+
const captureStdin = (onData) => {
|
|
8
|
+
stdin.setEncoding('utf-8');
|
|
9
|
+
stdin.setRawMode(true);
|
|
10
|
+
stdin.on('data', onData);
|
|
11
|
+
stdin.resume();
|
|
12
|
+
};
|
|
13
|
+
const releaseStdin = (onData) => {
|
|
14
|
+
stdin.pause();
|
|
15
|
+
stdin.removeListener('data', onData);
|
|
16
|
+
stdin.setRawMode(false);
|
|
17
|
+
stdout.write('\n');
|
|
18
|
+
};
|
|
19
|
+
const prompt = (question, ctrlcExits = true) => (new Promise((resolve, reject) => {
|
|
20
|
+
let input = '';
|
|
21
|
+
const onData = (data) => {
|
|
22
|
+
switch (data) {
|
|
23
|
+
case '\u000A': // \n
|
|
24
|
+
case '\u000D': // \r
|
|
25
|
+
case '\u0004': // Ctrl+D
|
|
26
|
+
releaseStdin(onData);
|
|
27
|
+
resolve(input);
|
|
28
|
+
break;
|
|
29
|
+
case '\u0003': // Ctrl+C
|
|
30
|
+
releaseStdin(onData);
|
|
31
|
+
if (ctrlcExits) { // exit or raise error
|
|
32
|
+
process.exit();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
reject(new Error('Ctrl+C'));
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
38
|
+
case '\u0008': // Backspace
|
|
39
|
+
case '\u007F': // Delete
|
|
40
|
+
input = input.slice(0, -1);
|
|
41
|
+
break;
|
|
42
|
+
default: // any other
|
|
43
|
+
input += data;
|
|
44
|
+
}
|
|
45
|
+
;
|
|
46
|
+
};
|
|
47
|
+
captureStdin(onData);
|
|
48
|
+
stdout.write(question);
|
|
49
|
+
}));
|
|
50
|
+
exports.prompt = prompt;
|
package/lib/tools/publish.cjs
CHANGED
|
@@ -22,14 +22,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const
|
|
26
|
+
const cli_1 = require("@hailer/cli");
|
|
30
27
|
const request = __importStar(require("request"));
|
|
31
28
|
const fs_1 = require("fs");
|
|
32
|
-
const minimal_password_prompt_1 =
|
|
29
|
+
const minimal_password_prompt_1 = require("minimal-password-prompt");
|
|
33
30
|
const util_1 = require("util");
|
|
34
31
|
const readline_1 = require("readline");
|
|
35
32
|
if (!process.env.EMAIL && !process.env.LOCAL) {
|
|
@@ -41,7 +38,7 @@ if (!process.env.EMAIL && !process.env.LOCAL) {
|
|
|
41
38
|
}
|
|
42
39
|
(async () => {
|
|
43
40
|
let email = process.env.EMAIL;
|
|
44
|
-
let password = process.env.LOCAL || await (0, minimal_password_prompt_1.
|
|
41
|
+
let password = process.env.LOCAL || await (0, minimal_password_prompt_1.prompt)('enter password for ' + email + ': ');
|
|
45
42
|
// Market code
|
|
46
43
|
const market = process.env.MARKET === 'true';
|
|
47
44
|
const appPackageFile = process.argv[2];
|
|
@@ -65,137 +62,136 @@ if (!process.env.EMAIL && !process.env.LOCAL) {
|
|
|
65
62
|
password = 'thispasswordshouldbestrongenough';
|
|
66
63
|
host = 'http://localhost:1337';
|
|
67
64
|
}
|
|
68
|
-
const cli =
|
|
69
|
-
if (!appPackageFile?.endsWith('.tgz')) {
|
|
70
|
-
console.log('Failed getting .tgz file, found:', appPackageFile);
|
|
71
|
-
process.exit(7);
|
|
72
|
-
}
|
|
73
|
-
cli.on('error', (error) => {
|
|
65
|
+
const cli = await cli_1.Client.create({ host, username: email, password }).catch((error) => {
|
|
74
66
|
if (error.msg === 'Invalid Login Data') {
|
|
75
67
|
console.log('Invalid username or password when logging into Hailer.');
|
|
76
|
-
process.exit(8);
|
|
77
68
|
}
|
|
78
|
-
|
|
69
|
+
else {
|
|
70
|
+
console.log('Hailer Cli Error:', error);
|
|
71
|
+
}
|
|
72
|
+
process.exit(8);
|
|
79
73
|
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
74
|
+
if (!appPackageFile?.endsWith('.tgz')) {
|
|
75
|
+
console.log('Failed getting .tgz file, found:', appPackageFile);
|
|
76
|
+
process.exit(7);
|
|
77
|
+
}
|
|
78
|
+
const manifest = JSON.parse((0, fs_1.readFileSync)('./dist/manifest.json').toString());
|
|
79
|
+
const content = (0, fs_1.readFileSync)(appPackageFile);
|
|
80
|
+
const info = await cli.request('v2.core.init', [['network', 'networks', 'apps']]);
|
|
81
|
+
// Market code
|
|
82
|
+
if (market) {
|
|
83
|
+
// Check if version exist in manifest.json. If not, add empty version and let user fill it in
|
|
84
|
+
if (!manifest.version) {
|
|
85
|
+
manifest.version = '';
|
|
86
|
+
manifest.versionDescription = '';
|
|
87
|
+
// Convert the modified object back to JSON
|
|
88
|
+
const updatedManifestContent = JSON.stringify(manifest, null, 2);
|
|
89
|
+
// Write the updated JSON content back to manifest.json
|
|
90
|
+
(0, fs_1.writeFileSync)('./public/manifest.json', updatedManifestContent, 'utf-8');
|
|
91
|
+
console.log('');
|
|
92
|
+
console.log('Please set version & versionDescription in file public/manifest.json! You have added MARKET=true in your publish string.');
|
|
93
|
+
console.log('');
|
|
94
|
+
process.exit(10);
|
|
99
95
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
96
|
+
}
|
|
97
|
+
const getAppById = (manifestAppId) => {
|
|
98
|
+
for (const appMap of Object.values(info.apps)) {
|
|
99
|
+
for (const [appId, app] of Object.entries(appMap)) {
|
|
100
|
+
if (appId === manifestAppId) {
|
|
101
|
+
return app;
|
|
106
102
|
}
|
|
107
103
|
}
|
|
108
|
-
return null;
|
|
109
|
-
};
|
|
110
|
-
const app = getAppById(manifest.appId);
|
|
111
|
-
if (!app) {
|
|
112
|
-
console.log('The app was not found using this user:', email);
|
|
113
|
-
process.exit(2);
|
|
114
|
-
}
|
|
115
|
-
const personalApp = !app.cid;
|
|
116
|
-
console.log('Publishing App');
|
|
117
|
-
console.log(' Id:', manifest.appId);
|
|
118
|
-
console.log(' Name:', app.name);
|
|
119
|
-
if (personalApp) {
|
|
120
|
-
console.log(' Workspace: any (personal app)');
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
console.log(' Workspace:', info.networks[app.cid]?.name, '(' + app.cid + ')');
|
|
124
|
-
}
|
|
125
|
-
console.log(' Environment:', host);
|
|
126
|
-
console.log();
|
|
127
|
-
// Market code
|
|
128
|
-
if (market) {
|
|
129
|
-
console.log(' Note: Also publishing app to Hailer market');
|
|
130
104
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
},
|
|
164
|
-
appId: manifest.appId,
|
|
165
|
-
// Market code
|
|
166
|
-
publishMarket: market.toString(),
|
|
105
|
+
return null;
|
|
106
|
+
};
|
|
107
|
+
const app = getAppById(manifest.appId);
|
|
108
|
+
if (!app) {
|
|
109
|
+
console.log('The app was not found using this user:', email);
|
|
110
|
+
process.exit(2);
|
|
111
|
+
}
|
|
112
|
+
const personalApp = !app.cid;
|
|
113
|
+
console.log('Publishing App');
|
|
114
|
+
console.log(' Id:', manifest.appId);
|
|
115
|
+
console.log(' Name:', app.name);
|
|
116
|
+
if (personalApp) {
|
|
117
|
+
console.log(' Workspace: any (personal app)');
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
console.log(' Workspace:', info.networks[app.cid]?.name, '(' + app.cid + ')');
|
|
121
|
+
}
|
|
122
|
+
console.log(' Environment:', host);
|
|
123
|
+
console.log();
|
|
124
|
+
// Market code
|
|
125
|
+
if (market) {
|
|
126
|
+
console.log(' Note: Also publishing app to Hailer market');
|
|
127
|
+
}
|
|
128
|
+
/** Default to publish (yes) */
|
|
129
|
+
const promptOverwriteQuestion = () => {
|
|
130
|
+
return new Promise(resolve => {
|
|
131
|
+
const rl = (0, readline_1.createInterface)(process.stdin, process.stdout);
|
|
132
|
+
rl.setPrompt('Overwrite the app? (Y/n): ');
|
|
133
|
+
rl.prompt();
|
|
134
|
+
rl.on('line', (line) => {
|
|
135
|
+
if (line.trim().toLocaleLowerCase().startsWith('n')) {
|
|
136
|
+
resolve(false);
|
|
167
137
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
console.log('Publish error uploading file:', error);
|
|
171
|
-
process.exit(9);
|
|
138
|
+
else {
|
|
139
|
+
resolve(true);
|
|
172
140
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
141
|
+
rl.close();
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
const shouldOverwrite = await promptOverwriteQuestion();
|
|
146
|
+
if (!shouldOverwrite) {
|
|
147
|
+
console.log('Aborted publishing app.');
|
|
148
|
+
process.exit(0);
|
|
149
|
+
}
|
|
150
|
+
await new Promise((resolve, reject) => {
|
|
151
|
+
request.post({
|
|
152
|
+
uri: host + '/app/publish',
|
|
153
|
+
headers: { hlrkey: cli.sessionKey },
|
|
154
|
+
formData: {
|
|
155
|
+
file: {
|
|
156
|
+
value: content,
|
|
157
|
+
options: {
|
|
158
|
+
filename: appPackageFile,
|
|
186
159
|
}
|
|
160
|
+
},
|
|
161
|
+
appId: manifest.appId,
|
|
162
|
+
// Market code
|
|
163
|
+
publishMarket: market.toString(),
|
|
164
|
+
}
|
|
165
|
+
}, function (error, resp, body) {
|
|
166
|
+
if (error) {
|
|
167
|
+
console.log('Publish error uploading file:', error);
|
|
168
|
+
process.exit(9);
|
|
169
|
+
}
|
|
170
|
+
let response;
|
|
171
|
+
let infoMarket = '';
|
|
172
|
+
try {
|
|
173
|
+
response = JSON.parse(body);
|
|
174
|
+
// Market code
|
|
175
|
+
if (response.manifest && response.manifest.targetId) {
|
|
176
|
+
infoMarket = 'Note! Use targetId in public/manifest.json file when creating the product in market!';
|
|
177
|
+
// Write targetId to manifest.json
|
|
178
|
+
manifest.targetId = response.manifest.targetId;
|
|
179
|
+
// Convert the modified object back to JSON
|
|
180
|
+
const updatedManifestContent = JSON.stringify(manifest, null, 2);
|
|
181
|
+
// Write the updated JSON content back to manifest.json
|
|
182
|
+
(0, fs_1.writeFileSync)('./public/manifest.json', updatedManifestContent, 'utf-8');
|
|
187
183
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
// ingore
|
|
187
|
+
}
|
|
188
|
+
console.log('App info:', (0, util_1.inspect)(response, { depth: 10, colors: true }));
|
|
189
|
+
console.log();
|
|
190
|
+
console.log(infoMarket);
|
|
191
|
+
console.log();
|
|
192
|
+
console.log('Published successfully!');
|
|
193
|
+
resolve();
|
|
198
194
|
});
|
|
199
|
-
cli.disconnect();
|
|
200
195
|
});
|
|
196
|
+
cli.disconnect();
|
|
201
197
|
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fs_1 = require("fs");
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const srcFolder = (0, path_1.join)(__dirname, '../src');
|
|
6
|
+
const publicSrcFolder = (0, path_1.join)(__dirname, '../public-src');
|
|
7
|
+
const replacePrivateComments = (fileContent) => {
|
|
8
|
+
// Replaces all occurences of /* @ private */ with private
|
|
9
|
+
return fileContent.replace(/\/\* @private \*\//g, 'private');
|
|
10
|
+
};
|
|
11
|
+
const copyAndReplaceFiles = (src, dest) => {
|
|
12
|
+
(0, fs_1.mkdirSync)(dest, { recursive: true });
|
|
13
|
+
console.log('Created folder: ', dest);
|
|
14
|
+
(0, fs_1.readdirSync)(src).forEach((file) => {
|
|
15
|
+
const srcFile = (0, path_1.join)(src, file);
|
|
16
|
+
const destFile = (0, path_1.join)(dest, file);
|
|
17
|
+
if ((0, fs_1.lstatSync)(srcFile).isDirectory()) {
|
|
18
|
+
copyAndReplaceFiles(srcFile, destFile);
|
|
19
|
+
}
|
|
20
|
+
else if (srcFile.endsWith('.ts')) {
|
|
21
|
+
const updatedContent = replacePrivateComments((0, fs_1.readFileSync)(srcFile, 'utf8'));
|
|
22
|
+
(0, fs_1.writeFileSync)(destFile, updatedContent, 'utf8');
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
(0, fs_1.copyFileSync)(srcFile, destFile);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
if ((0, fs_1.existsSync)(publicSrcFolder)) {
|
|
30
|
+
(0, fs_1.rmdirSync)(publicSrcFolder, { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
copyAndReplaceFiles(srcFolder, publicSrcFolder);
|
|
33
|
+
console.log('Public source files generated in /public-src/');
|