@dextinity/cli 2.0.0-canary-20260729062014
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 +24 -0
- package/bin/comet.js +3 -0
- package/lib/BlockMeta.d.ts +41 -0
- package/lib/BlockMeta.js +2 -0
- package/lib/comet.d.ts +1 -0
- package/lib/comet.js +15 -0
- package/lib/commands/download-mitmproxy.d.ts +2 -0
- package/lib/commands/download-mitmproxy.js +141 -0
- package/lib/commands/download-oauth2-proxy.d.ts +2 -0
- package/lib/commands/download-oauth2-proxy.js +134 -0
- package/lib/commands/generate-block-types.d.ts +3 -0
- package/lib/commands/generate-block-types.js +192 -0
- package/lib/commands/install-agent-features.d.ts +7 -0
- package/lib/commands/install-agent-features.js +434 -0
- package/lib/commands/site-configs.d.ts +3 -0
- package/lib/commands/site-configs.js +272 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/site-configs.types.d.ts +17 -0
- package/lib/site-configs.types.js +2 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
BSD 2-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023, Vivid Planet Software GmbH
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
17
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
19
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
20
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
21
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
23
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
24
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/bin/comet.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface BlockMeta {
|
|
2
|
+
name: string;
|
|
3
|
+
fields: BlockMetaField[];
|
|
4
|
+
inputFields: BlockMetaField[];
|
|
5
|
+
}
|
|
6
|
+
export type BlockMetaField = {
|
|
7
|
+
name: string;
|
|
8
|
+
kind: "String" | "Number" | "Boolean" | "Json";
|
|
9
|
+
nullable: boolean;
|
|
10
|
+
array?: boolean;
|
|
11
|
+
} | {
|
|
12
|
+
name: string;
|
|
13
|
+
kind: "TipTapRichTextBlock";
|
|
14
|
+
nullable: boolean;
|
|
15
|
+
childBlocks: Record<string, string>;
|
|
16
|
+
} | {
|
|
17
|
+
name: string;
|
|
18
|
+
kind: "Enum";
|
|
19
|
+
nullable: boolean;
|
|
20
|
+
enum: string[];
|
|
21
|
+
array?: boolean;
|
|
22
|
+
} | {
|
|
23
|
+
name: string;
|
|
24
|
+
kind: "Block";
|
|
25
|
+
nullable: boolean;
|
|
26
|
+
block: string;
|
|
27
|
+
} | {
|
|
28
|
+
name: string;
|
|
29
|
+
kind: "OneOfBlocks";
|
|
30
|
+
nullable: boolean;
|
|
31
|
+
blocks: Record<string, string>;
|
|
32
|
+
} | {
|
|
33
|
+
name: string;
|
|
34
|
+
kind: "NestedObject" | "NestedObjectList";
|
|
35
|
+
nullable: boolean;
|
|
36
|
+
object: BlockMetaNestedObject;
|
|
37
|
+
};
|
|
38
|
+
interface BlockMetaNestedObject {
|
|
39
|
+
fields: BlockMetaField[];
|
|
40
|
+
}
|
|
41
|
+
export {};
|
package/lib/BlockMeta.js
ADDED
package/lib/comet.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/comet.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var commander_1 = require("commander");
|
|
4
|
+
var download_mitmproxy_1 = require("./commands/download-mitmproxy");
|
|
5
|
+
var download_oauth2_proxy_1 = require("./commands/download-oauth2-proxy");
|
|
6
|
+
var generate_block_types_1 = require("./commands/generate-block-types");
|
|
7
|
+
var install_agent_features_1 = require("./commands/install-agent-features");
|
|
8
|
+
var site_configs_1 = require("./commands/site-configs");
|
|
9
|
+
var program = new commander_1.Command();
|
|
10
|
+
program.addCommand(generate_block_types_1.generateBlockTypes);
|
|
11
|
+
program.addCommand(site_configs_1.injectSiteConfigsCommand);
|
|
12
|
+
program.addCommand(download_oauth2_proxy_1.downloadOAuth2ProxyCommand);
|
|
13
|
+
program.addCommand(download_mitmproxy_1.downloadMitmproxyCommand);
|
|
14
|
+
program.addCommand(install_agent_features_1.installAgentFeaturesCommand);
|
|
15
|
+
program.parse();
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
45
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
46
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
47
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
48
|
+
function step(op) {
|
|
49
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
50
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
51
|
+
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;
|
|
52
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
53
|
+
switch (op[0]) {
|
|
54
|
+
case 0: case 1: t = op; break;
|
|
55
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
56
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
57
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
58
|
+
default:
|
|
59
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
60
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
61
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
62
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
63
|
+
if (t[2]) _.ops.pop();
|
|
64
|
+
_.trys.pop(); continue;
|
|
65
|
+
}
|
|
66
|
+
op = body.call(thisArg, _);
|
|
67
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
68
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
72
|
+
exports.downloadMitmproxyCommand = void 0;
|
|
73
|
+
/* eslint-disable no-console */
|
|
74
|
+
var child_process_1 = require("child_process");
|
|
75
|
+
var commander_1 = require("commander");
|
|
76
|
+
var fs = __importStar(require("fs"));
|
|
77
|
+
var os = __importStar(require("os"));
|
|
78
|
+
function getPlatform() {
|
|
79
|
+
var platform = os.platform();
|
|
80
|
+
switch (platform) {
|
|
81
|
+
case "linux":
|
|
82
|
+
return "linux";
|
|
83
|
+
case "darwin":
|
|
84
|
+
return "macos";
|
|
85
|
+
case "win32":
|
|
86
|
+
return "windows";
|
|
87
|
+
default:
|
|
88
|
+
throw new Error("Unsupported platform: ".concat(platform));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function getArchitecture() {
|
|
92
|
+
var arch = os.arch();
|
|
93
|
+
switch (arch) {
|
|
94
|
+
case "x64":
|
|
95
|
+
return "x86_64";
|
|
96
|
+
case "arm64":
|
|
97
|
+
return "arm64";
|
|
98
|
+
default:
|
|
99
|
+
throw new Error("Unsupported architecture: ".concat(arch));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.downloadMitmproxyCommand = new commander_1.Command("download-mitmproxy")
|
|
103
|
+
.description("Download the Mitmproxy binary")
|
|
104
|
+
.requiredOption("-v, --version <version>", "Specify the version of the Mitmproxy to download (e.g. v12.2.0).")
|
|
105
|
+
.action(function (options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
|
+
var version, platform, architecture, downloadUrl, baseDir, dirname, existingFiles, _i, existingFiles_1, file, filename;
|
|
107
|
+
return __generator(this, function (_a) {
|
|
108
|
+
console.log("=== Installing mitmproxy ===");
|
|
109
|
+
version = options.version.startsWith("v") ? options.version.slice(1) : options.version;
|
|
110
|
+
platform = getPlatform();
|
|
111
|
+
architecture = getArchitecture();
|
|
112
|
+
downloadUrl = "https://downloads.mitmproxy.org/".concat(version, "/mitmproxy-").concat(version, "-").concat(platform, "-").concat(architecture, ".").concat(platform == "windows" ? "zip" : "tar.gz");
|
|
113
|
+
baseDir = "".concat(process.cwd(), "/node_modules");
|
|
114
|
+
dirname = "mitmproxy-".concat(version, ".").concat(platform, "-").concat(architecture);
|
|
115
|
+
existingFiles = fs.readdirSync(baseDir).filter(function (f) { return f.startsWith("mitmproxy-") && f !== dirname; });
|
|
116
|
+
for (_i = 0, existingFiles_1 = existingFiles; _i < existingFiles_1.length; _i++) {
|
|
117
|
+
file = existingFiles_1[_i];
|
|
118
|
+
console.log("Deleting old version: ".concat(file));
|
|
119
|
+
fs.rmSync("".concat(baseDir, "/").concat(file), { recursive: true, force: true });
|
|
120
|
+
}
|
|
121
|
+
filename = "".concat(baseDir, "/").concat(dirname);
|
|
122
|
+
if (fs.existsSync(filename)) {
|
|
123
|
+
console.log("Mitmproxy version ".concat(version, " already installed."));
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
console.log("Downloading and extracting Mitmproxy version ".concat(version, "..."));
|
|
127
|
+
fs.mkdirSync("".concat(baseDir, "/").concat(dirname), { recursive: true });
|
|
128
|
+
(0, child_process_1.execSync)("curl -s -L ".concat(downloadUrl, " | tar xvfz - -C ").concat(baseDir, "/").concat(dirname), { stdio: "inherit" });
|
|
129
|
+
}
|
|
130
|
+
// Create symlink to have a consistent name
|
|
131
|
+
console.log("Create symlink to mitmweb binary on ".concat(baseDir, "/.bin/mitmweb"));
|
|
132
|
+
if (os.platform() === "darwin") {
|
|
133
|
+
(0, child_process_1.execSync)("ln -sf ../".concat(dirname, "/mitmproxy.app/Contents/MacOS/mitmweb ").concat(baseDir, "/.bin/mitmweb"));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
(0, child_process_1.execSync)("ln -sf ../".concat(dirname, "/mitmweb ").concat(baseDir, "/.bin/mitmweb"));
|
|
137
|
+
}
|
|
138
|
+
console.log("=== Finished installing Mitmproxy ===");
|
|
139
|
+
return [2 /*return*/];
|
|
140
|
+
});
|
|
141
|
+
}); });
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
45
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
46
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
47
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
48
|
+
function step(op) {
|
|
49
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
50
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
51
|
+
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;
|
|
52
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
53
|
+
switch (op[0]) {
|
|
54
|
+
case 0: case 1: t = op; break;
|
|
55
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
56
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
57
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
58
|
+
default:
|
|
59
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
60
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
61
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
62
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
63
|
+
if (t[2]) _.ops.pop();
|
|
64
|
+
_.trys.pop(); continue;
|
|
65
|
+
}
|
|
66
|
+
op = body.call(thisArg, _);
|
|
67
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
68
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
72
|
+
exports.downloadOAuth2ProxyCommand = void 0;
|
|
73
|
+
/* eslint-disable no-console */
|
|
74
|
+
var child_process_1 = require("child_process");
|
|
75
|
+
var commander_1 = require("commander");
|
|
76
|
+
var fs = __importStar(require("fs"));
|
|
77
|
+
var os = __importStar(require("os"));
|
|
78
|
+
function getPlatform() {
|
|
79
|
+
var platform = os.platform();
|
|
80
|
+
switch (platform) {
|
|
81
|
+
case "linux":
|
|
82
|
+
return "linux";
|
|
83
|
+
case "darwin":
|
|
84
|
+
return "darwin";
|
|
85
|
+
case "win32":
|
|
86
|
+
return "windows";
|
|
87
|
+
default:
|
|
88
|
+
throw new Error("Unsupported platform: ".concat(platform));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function getArchitecture() {
|
|
92
|
+
var arch = os.arch();
|
|
93
|
+
switch (arch) {
|
|
94
|
+
case "x64":
|
|
95
|
+
return "amd64";
|
|
96
|
+
case "arm64":
|
|
97
|
+
return "arm64";
|
|
98
|
+
default:
|
|
99
|
+
throw new Error("Unsupported architecture: ".concat(arch));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.downloadOAuth2ProxyCommand = new commander_1.Command("download-oauth2-proxy")
|
|
103
|
+
.description("Download the OAuth2 Proxy binary")
|
|
104
|
+
.requiredOption("-v, --version <version>", "Specify the version of the OAuth2 Proxy to download (e.g. v7.12.0).")
|
|
105
|
+
.action(function (options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
|
+
var version, platform, architecture, baseDir, dirname, existingFiles, _i, existingFiles_1, file, filename;
|
|
107
|
+
return __generator(this, function (_a) {
|
|
108
|
+
console.log("=== Installing oauth2-proxy ===");
|
|
109
|
+
version = options.version;
|
|
110
|
+
platform = getPlatform();
|
|
111
|
+
architecture = getArchitecture();
|
|
112
|
+
baseDir = "".concat(process.cwd(), "/node_modules");
|
|
113
|
+
dirname = "oauth2-proxy-".concat(version, ".").concat(platform, "-").concat(architecture);
|
|
114
|
+
existingFiles = fs.readdirSync(baseDir).filter(function (f) { return f.startsWith("oauth2-proxy-v") && f !== dirname; });
|
|
115
|
+
for (_i = 0, existingFiles_1 = existingFiles; _i < existingFiles_1.length; _i++) {
|
|
116
|
+
file = existingFiles_1[_i];
|
|
117
|
+
console.log("Deleting old version: ".concat(file));
|
|
118
|
+
fs.rmSync("".concat(baseDir, "/").concat(file), { recursive: true, force: true });
|
|
119
|
+
}
|
|
120
|
+
filename = "".concat(baseDir, "/").concat(dirname, "/oauth2-proxy");
|
|
121
|
+
if (fs.existsSync(filename)) {
|
|
122
|
+
console.log("OAuth2-Proxy version ".concat(version, " already installed."));
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
console.log("Downloading and extracting OAuth2-Proxy version ".concat(version, "..."));
|
|
126
|
+
(0, child_process_1.execSync)("curl -s -L https://github.com/oauth2-proxy/oauth2-proxy/releases/download/".concat(version, "/oauth2-proxy-").concat(version, ".").concat(platform, "-").concat(architecture, ".tar.gz | tar xvfz - -C ").concat(baseDir), { stdio: "inherit" });
|
|
127
|
+
}
|
|
128
|
+
// Create symlink to have a consistent name
|
|
129
|
+
console.log("Create symlink to oauth2-proxy binary on ".concat(baseDir, "/.bin/oauth2-proxy"));
|
|
130
|
+
(0, child_process_1.execSync)("ln -sf ../".concat(dirname, "/oauth2-proxy ").concat(baseDir, "/.bin/oauth2-proxy"));
|
|
131
|
+
console.log("=== Finished installing OAuth2-Proxy ===");
|
|
132
|
+
return [2 /*return*/];
|
|
133
|
+
});
|
|
134
|
+
}); });
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.generateBlockTypes = void 0;
|
|
51
|
+
var commander_1 = require("commander");
|
|
52
|
+
var promises_1 = require("fs/promises");
|
|
53
|
+
var prettier_1 = require("prettier");
|
|
54
|
+
var content = "";
|
|
55
|
+
function writeFieldType(field, blockNamePostfix) {
|
|
56
|
+
if (field.kind === "String") {
|
|
57
|
+
content += "string";
|
|
58
|
+
if (field.array) {
|
|
59
|
+
content += "[]";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if (field.kind === "Number") {
|
|
63
|
+
content += "number";
|
|
64
|
+
if (field.array) {
|
|
65
|
+
content += "[]";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else if (field.kind === "Boolean") {
|
|
69
|
+
content += "boolean";
|
|
70
|
+
if (field.array) {
|
|
71
|
+
content += "[]";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else if (field.kind === "Json") {
|
|
75
|
+
content += "unknown";
|
|
76
|
+
if (field.array) {
|
|
77
|
+
content += "[]";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else if (field.kind === "TipTapRichTextBlock") {
|
|
81
|
+
content += "unknown";
|
|
82
|
+
}
|
|
83
|
+
else if (field.kind === "Enum") {
|
|
84
|
+
var enumType = "\"".concat(field.enum.join('" | "'), "\"");
|
|
85
|
+
content += field.array ? "(".concat(enumType, ")[]") : enumType;
|
|
86
|
+
}
|
|
87
|
+
else if (field.kind === "Block") {
|
|
88
|
+
content += "".concat(field.block).concat(blockNamePostfix);
|
|
89
|
+
}
|
|
90
|
+
else if (field.kind === "OneOfBlocks") {
|
|
91
|
+
if (Object.values(field.blocks).length < 1) {
|
|
92
|
+
content += "{}";
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
content += Object.values(field.blocks)
|
|
96
|
+
.map(function (i) {
|
|
97
|
+
return "".concat(i).concat(blockNamePostfix);
|
|
98
|
+
})
|
|
99
|
+
.join(" | ");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else if (field.kind === "NestedObject") {
|
|
103
|
+
content += "{\n";
|
|
104
|
+
field.object.fields.forEach(function (f) {
|
|
105
|
+
content += f.name;
|
|
106
|
+
if (f.nullable) {
|
|
107
|
+
content += "?";
|
|
108
|
+
}
|
|
109
|
+
content += ": ";
|
|
110
|
+
writeFieldType(f, blockNamePostfix);
|
|
111
|
+
content += ";\n";
|
|
112
|
+
});
|
|
113
|
+
content += "}\n";
|
|
114
|
+
}
|
|
115
|
+
else if (field.kind === "NestedObjectList") {
|
|
116
|
+
content += "Array<{\n";
|
|
117
|
+
field.object.fields.forEach(function (f) {
|
|
118
|
+
content += f.name;
|
|
119
|
+
if (f.nullable) {
|
|
120
|
+
content += "?";
|
|
121
|
+
}
|
|
122
|
+
content += ": ";
|
|
123
|
+
writeFieldType(f, blockNamePostfix);
|
|
124
|
+
content += ";\n";
|
|
125
|
+
});
|
|
126
|
+
content += "}>\n";
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
var generateAllBlockNames = function (blockMeta) {
|
|
130
|
+
var uniqueBlockNames = Array.from(new Set(blockMeta.map(function (block) { return block.name; }))).sort();
|
|
131
|
+
var content = "export type AllBlockNames =";
|
|
132
|
+
uniqueBlockNames.forEach(function (blockName) {
|
|
133
|
+
content += " | \"".concat(blockName, "\"");
|
|
134
|
+
});
|
|
135
|
+
return content;
|
|
136
|
+
};
|
|
137
|
+
var generateBlockTypes = new commander_1.Command("generate-block-types")
|
|
138
|
+
.description("generate block types from block meta")
|
|
139
|
+
.option("--inputs", "include block inputs")
|
|
140
|
+
.option("--input-file <inputFile>", "file to read block meta from", "block-meta.json")
|
|
141
|
+
.option("--output-file <outputFile>", "file to write block types to", "./src/blocks.generated.ts")
|
|
142
|
+
.action(function (options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
143
|
+
var blockMeta, sortedBlockMeta, prettierOptions;
|
|
144
|
+
return __generator(this, function (_a) {
|
|
145
|
+
switch (_a.label) {
|
|
146
|
+
case 0: return [4 /*yield*/, (0, promises_1.readFile)(options.inputFile).then(function (fileContents) { return JSON.parse(fileContents.toString()); })];
|
|
147
|
+
case 1:
|
|
148
|
+
blockMeta = _a.sent();
|
|
149
|
+
sortedBlockMeta = blockMeta.sort(function (a, b) { return a.name.localeCompare(b.name); });
|
|
150
|
+
sortedBlockMeta.forEach(function (block) {
|
|
151
|
+
content += "export interface ".concat(block.name, "BlockData {\n");
|
|
152
|
+
block.fields.forEach(function (field) {
|
|
153
|
+
content += field.name;
|
|
154
|
+
if (field.nullable) {
|
|
155
|
+
content += "?";
|
|
156
|
+
}
|
|
157
|
+
content += ": ";
|
|
158
|
+
writeFieldType(field, "BlockData");
|
|
159
|
+
content += ";\n";
|
|
160
|
+
});
|
|
161
|
+
content += "}\n";
|
|
162
|
+
});
|
|
163
|
+
if (options.inputs) {
|
|
164
|
+
sortedBlockMeta.forEach(function (block) {
|
|
165
|
+
content += "export interface ".concat(block.name, "BlockInput {\n");
|
|
166
|
+
block.inputFields.forEach(function (field) {
|
|
167
|
+
content += field.name;
|
|
168
|
+
if (field.nullable) {
|
|
169
|
+
content += "?";
|
|
170
|
+
}
|
|
171
|
+
content += ": ";
|
|
172
|
+
writeFieldType(field, "BlockInput");
|
|
173
|
+
content += ";\n";
|
|
174
|
+
});
|
|
175
|
+
content += "}\n";
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
content += generateAllBlockNames(blockMeta);
|
|
179
|
+
return [4 /*yield*/, (0, prettier_1.resolveConfig)(process.cwd())];
|
|
180
|
+
case 2:
|
|
181
|
+
prettierOptions = _a.sent();
|
|
182
|
+
return [4 /*yield*/, (0, prettier_1.format)(content, __assign(__assign({}, prettierOptions), { parser: "typescript" }))];
|
|
183
|
+
case 3:
|
|
184
|
+
content = _a.sent();
|
|
185
|
+
return [4 /*yield*/, (0, promises_1.writeFile)(options.outputFile, content)];
|
|
186
|
+
case 4:
|
|
187
|
+
_a.sent();
|
|
188
|
+
return [2 /*return*/];
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}); });
|
|
192
|
+
exports.generateBlockTypes = generateBlockTypes;
|