@pipelab/plugin-construct 1.0.0-beta.0
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/CHANGELOG.md +12 -0
- package/LICENSE +110 -0
- package/README.md +3 -0
- package/dist/index.cjs +433 -0
- package/dist/index.d.cts +132 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +132 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +428 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +50 -0
- package/src/assets/construct.webp +0 -0
- package/src/assets/script.ts +288 -0
- package/src/declarations.d.ts +1 -0
- package/src/export-c3p.ts +75 -0
- package/src/export-project.ts +75 -0
- package/src/export-shared.ts +286 -0
- package/src/export.test.ts +37 -0
- package/src/index.ts +34 -0
- package/tests/e2e/construct.spec.ts +60 -0
- package/tests/e2e/fixtures/c3-export/test.c3p +0 -0
- package/tests/e2e/fixtures/c3-export.json +51 -0
- package/tests/e2e/fixtures/html-export/index.html +29 -0
- package/tests/e2e/vitest.config.mts +20 -0
- package/tsconfig.json +10 -0
- package/tsdown.config.ts +15 -0
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipelab/plugin-construct",
|
|
3
|
+
"version": "1.0.0-beta.0",
|
|
4
|
+
"license": "FSL-1.1-MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/CynToolkit/pipelab.git",
|
|
8
|
+
"directory": "plugins/plugin-construct"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "./dist/index.cjs",
|
|
12
|
+
"module": "./dist/index.mjs",
|
|
13
|
+
"types": "./dist/index.d.mts",
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"es-toolkit": "1.25.2",
|
|
19
|
+
"playwright": "1.48.2",
|
|
20
|
+
"valibot": "0.42.1",
|
|
21
|
+
"@pipelab/plugin-core": "1.0.0-beta.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "24",
|
|
25
|
+
"tsdown": "0.21.2",
|
|
26
|
+
"typescript": "5.9.3",
|
|
27
|
+
"vitest": "3.1.4",
|
|
28
|
+
"@pipelab/test-utils": "1.0.0-beta.0",
|
|
29
|
+
"@pipelab/tsconfig": "1.0.0-beta.0"
|
|
30
|
+
},
|
|
31
|
+
"test": {
|
|
32
|
+
"env": {
|
|
33
|
+
"NODE_ENV": "development"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"format": "oxfmt .",
|
|
38
|
+
"lint": "oxlint .",
|
|
39
|
+
"build": "tsdown",
|
|
40
|
+
"test": "vitest run -c tests/e2e/vitest.config.mts"
|
|
41
|
+
},
|
|
42
|
+
"exports": {
|
|
43
|
+
".": {
|
|
44
|
+
"types": "./dist/index.d.mts",
|
|
45
|
+
"import": "./dist/index.mjs",
|
|
46
|
+
"require": "./dist/index.cjs",
|
|
47
|
+
"default": "./dist/index.mjs"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { Page } from "playwright";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
const registerInstallButtonListener = (page: Page, log: typeof console.log) => {
|
|
5
|
+
// as soon as it appear, without blocking flow
|
|
6
|
+
// accept installing plugins
|
|
7
|
+
const installDialog = page.locator("#addonConfirmInstallDialog");
|
|
8
|
+
const installBtn = installDialog.locator(".okButton");
|
|
9
|
+
installBtn
|
|
10
|
+
.waitFor({
|
|
11
|
+
timeout: 0,
|
|
12
|
+
})
|
|
13
|
+
.then(async () => {
|
|
14
|
+
await installBtn.click();
|
|
15
|
+
log("installBtn clicked");
|
|
16
|
+
registerInstallButtonListener(page, log);
|
|
17
|
+
})
|
|
18
|
+
.catch(async (e) => {
|
|
19
|
+
if (e.message.includes("Target page, context or browser has been closed")) return;
|
|
20
|
+
log("installBtn.click() failed", e.message);
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const registerSaveLoginExpiredistener = (page: Page, log: typeof console.log) => {
|
|
25
|
+
// as soon as it appear, without blocking flow
|
|
26
|
+
// accept installing plugins
|
|
27
|
+
const installDialog = page.locator("#confirmDialog");
|
|
28
|
+
const cancelBtn = installDialog.locator(".cancelConfirmButton");
|
|
29
|
+
cancelBtn
|
|
30
|
+
.waitFor({
|
|
31
|
+
timeout: 0,
|
|
32
|
+
})
|
|
33
|
+
.then(async () => {
|
|
34
|
+
await cancelBtn.click();
|
|
35
|
+
log("cancelBtn clicked");
|
|
36
|
+
registerSaveLoginExpiredistener(page, log);
|
|
37
|
+
})
|
|
38
|
+
.catch(async (e) => {
|
|
39
|
+
if (e.message.includes("Target page, context or browser has been closed")) return;
|
|
40
|
+
log("cancelBtn.click() failed", e.message);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const registerWebglErrorListener = (page: Page, log: typeof console.log) => {
|
|
45
|
+
// as soon as it appear, without blocking flow
|
|
46
|
+
// ignore webgl error
|
|
47
|
+
const okDialog = page.locator("#okDialog");
|
|
48
|
+
const webglErrorButton = okDialog.locator(".okButton");
|
|
49
|
+
webglErrorButton
|
|
50
|
+
.waitFor({
|
|
51
|
+
timeout: 0,
|
|
52
|
+
})
|
|
53
|
+
.then(async () => {
|
|
54
|
+
const text = await okDialog.allInnerTexts();
|
|
55
|
+
|
|
56
|
+
if (text.join().toLowerCase().includes("webgl")) {
|
|
57
|
+
await webglErrorButton.click();
|
|
58
|
+
log("webglErrorButton clicked");
|
|
59
|
+
registerWebglErrorListener(page, log);
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
.catch(async (e) => {
|
|
63
|
+
if (e.message.includes("Target page, context or browser has been closed")) return;
|
|
64
|
+
log("webglErrorButton.click() failed", e.message);
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
const registerDeprecatedFeatures = (page: Page, log: typeof console.log) => {
|
|
68
|
+
// as soon as it appear, without blocking flow
|
|
69
|
+
// ignore deprecated feature
|
|
70
|
+
const deprecatedFeaturesDialog = page.locator("#deprecatedFeaturesDialog");
|
|
71
|
+
const okButton = deprecatedFeaturesDialog.locator(".okButton");
|
|
72
|
+
okButton
|
|
73
|
+
.waitFor({
|
|
74
|
+
timeout: 0,
|
|
75
|
+
})
|
|
76
|
+
.then(async () => {
|
|
77
|
+
await okButton.click();
|
|
78
|
+
log("okButton clicked");
|
|
79
|
+
registerDeprecatedFeatures(page, log);
|
|
80
|
+
})
|
|
81
|
+
.catch(async (e) => {
|
|
82
|
+
if (e.message.includes("Target page, context or browser has been closed")) return;
|
|
83
|
+
log("deprecatedFeatures.okButton.click() failed", e.message);
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
const registerWelcomeToConstructListener = (page: Page, log: typeof console.log) => {
|
|
87
|
+
// as soon as it appear, without blocking flow
|
|
88
|
+
// ignore deprecated feature
|
|
89
|
+
const welcomeTourDialog = page.locator("#welcomeTourDialog");
|
|
90
|
+
const okButton = welcomeTourDialog.locator(".noThanksLink");
|
|
91
|
+
okButton
|
|
92
|
+
.waitFor({
|
|
93
|
+
timeout: 0,
|
|
94
|
+
})
|
|
95
|
+
.then(async () => {
|
|
96
|
+
await okButton.click();
|
|
97
|
+
log("okButton clicked");
|
|
98
|
+
// registerWelcomeToConstructListener(page, log); // usually only once
|
|
99
|
+
})
|
|
100
|
+
.catch(async (e) => {
|
|
101
|
+
if (e.message.includes("Target page, context or browser has been closed")) return;
|
|
102
|
+
log("welcomeTour.okButton.click() failed", e.message);
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const registerMissingAddonErrorListener = (page: Page, log: typeof console.log) => {
|
|
107
|
+
// as soon as it appear, without blocking flow
|
|
108
|
+
// ignore missing addon and throw
|
|
109
|
+
const okDialog = page.locator("#missingAddonsDialog");
|
|
110
|
+
const webglErrorButton = okDialog.locator(".okButton");
|
|
111
|
+
webglErrorButton
|
|
112
|
+
.waitFor({
|
|
113
|
+
timeout: 0,
|
|
114
|
+
})
|
|
115
|
+
.then(async () => {
|
|
116
|
+
throw new Error("Missing addon. You should bundle addons with your project");
|
|
117
|
+
})
|
|
118
|
+
.catch(async (e) => {
|
|
119
|
+
if (e.message.includes("Target page, context or browser has been closed")) return;
|
|
120
|
+
log("missingAddon.okButton.waitFor() failed", e.message);
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const registerNewVersionAvailableListener = (page: Page, log: typeof console.log) => {
|
|
125
|
+
// as soon as it appear, without blocking flow
|
|
126
|
+
// ignore new version available and throw
|
|
127
|
+
const newVersionAvailableDialog = page.locator("#confirmDialog");
|
|
128
|
+
const cancelButton = newVersionAvailableDialog.locator(".cancelConfirmButton");
|
|
129
|
+
cancelButton
|
|
130
|
+
.waitFor({
|
|
131
|
+
timeout: 0,
|
|
132
|
+
})
|
|
133
|
+
.then(async () => {
|
|
134
|
+
await cancelButton.click();
|
|
135
|
+
log("cancelButton clicked");
|
|
136
|
+
registerNewVersionAvailableListener(page, log);
|
|
137
|
+
})
|
|
138
|
+
.catch(async (e) => {
|
|
139
|
+
if (e.message.includes("Target page, context or browser has been closed")) return;
|
|
140
|
+
log("cancelButton.click() failed", e.message);
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export const script = async (
|
|
145
|
+
page: Page,
|
|
146
|
+
log: typeof console.log,
|
|
147
|
+
filePath: string,
|
|
148
|
+
username: string | undefined,
|
|
149
|
+
password: string | undefined,
|
|
150
|
+
version: string | undefined,
|
|
151
|
+
downloadDir: string,
|
|
152
|
+
) => {
|
|
153
|
+
let url = "https://editor.construct.net/";
|
|
154
|
+
if (version) {
|
|
155
|
+
url += version;
|
|
156
|
+
}
|
|
157
|
+
log("Navigating to URL", url);
|
|
158
|
+
// const serviceWorkerPromise = page.waitForEvent("serviceworker");
|
|
159
|
+
await page.goto(url);
|
|
160
|
+
log("after navigating");
|
|
161
|
+
|
|
162
|
+
// const serviceworker = await serviceWorkerPromise;
|
|
163
|
+
registerWelcomeToConstructListener(page, log);
|
|
164
|
+
registerNewVersionAvailableListener(page, log);
|
|
165
|
+
|
|
166
|
+
log("after event");
|
|
167
|
+
|
|
168
|
+
await page.waitForTimeout(2000);
|
|
169
|
+
log("after wait");
|
|
170
|
+
|
|
171
|
+
if (username && password) {
|
|
172
|
+
log("Authenticating");
|
|
173
|
+
await page.getByTitle("User account").locator("ui-icon").click();
|
|
174
|
+
await page.getByRole("menuitem", { name: "Log in" }).locator("span").click();
|
|
175
|
+
await page.frameLocator("#loginDialog iframe").getByLabel("Username").fill(username);
|
|
176
|
+
await page.frameLocator("#loginDialog iframe").getByLabel("Password").fill(password);
|
|
177
|
+
|
|
178
|
+
const tokenPromise = page.waitForResponse(/https:\/\/account.*\.construct\.net\/login.json/i);
|
|
179
|
+
|
|
180
|
+
await page.frameLocator("#loginDialog iframe").getByRole("button", { name: "Log in" }).click();
|
|
181
|
+
|
|
182
|
+
const response = await tokenPromise;
|
|
183
|
+
const jsonResponse = await response.json();
|
|
184
|
+
|
|
185
|
+
if (jsonResponse.request.status === "error") {
|
|
186
|
+
await page.close();
|
|
187
|
+
|
|
188
|
+
throw new Error("Invalid credentials");
|
|
189
|
+
}
|
|
190
|
+
log("Authenticated");
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
await page.waitForTimeout(2000);
|
|
194
|
+
|
|
195
|
+
const [fileChooser] = await Promise.all([
|
|
196
|
+
page.waitForEvent("filechooser"),
|
|
197
|
+
page.keyboard.press("ControlOrMeta+O"),
|
|
198
|
+
]);
|
|
199
|
+
log("filechooser");
|
|
200
|
+
|
|
201
|
+
console.log("filePath", filePath);
|
|
202
|
+
await fileChooser.setFiles([filePath]);
|
|
203
|
+
log("Set file");
|
|
204
|
+
|
|
205
|
+
// await page.getByText("Not now").click({
|
|
206
|
+
// timeout: 1000
|
|
207
|
+
// });
|
|
208
|
+
|
|
209
|
+
const progressDialog = page.locator("#progressDialog");
|
|
210
|
+
// <progress class="progressBar" value="0.293996941070648" max="1"></progress>
|
|
211
|
+
const progessBar = progressDialog.locator(".progressBar");
|
|
212
|
+
|
|
213
|
+
log("Waiting for progress dialog");
|
|
214
|
+
await progressDialog.waitFor({
|
|
215
|
+
timeout: 0,
|
|
216
|
+
});
|
|
217
|
+
log("Got loading progress dialog");
|
|
218
|
+
|
|
219
|
+
const progressInterval = setInterval(async () => {
|
|
220
|
+
const text = await progessBar.getAttribute("value");
|
|
221
|
+
const textAsNumber = parseFloat(text);
|
|
222
|
+
const finalText = Number.isNaN(textAsNumber) ? 0 : textAsNumber;
|
|
223
|
+
log("progress", `${finalText * 100}%`);
|
|
224
|
+
}, 500);
|
|
225
|
+
|
|
226
|
+
// as soon as it appear, without blocking flow
|
|
227
|
+
// ignore asking for update
|
|
228
|
+
const notNowBtn = page.getByText("Not now");
|
|
229
|
+
notNowBtn
|
|
230
|
+
.waitFor({
|
|
231
|
+
timeout: 0,
|
|
232
|
+
})
|
|
233
|
+
.then(async () => {
|
|
234
|
+
return notNowBtn.click();
|
|
235
|
+
})
|
|
236
|
+
.then(() => {
|
|
237
|
+
log("notNowBtn clicked");
|
|
238
|
+
})
|
|
239
|
+
.catch(async (e) => {
|
|
240
|
+
if (e.message.includes("Target page, context or browser has been closed")) return;
|
|
241
|
+
log("notNowBtn.click() failed", e.message);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
registerInstallButtonListener(page, log);
|
|
245
|
+
registerWebglErrorListener(page, log);
|
|
246
|
+
registerMissingAddonErrorListener(page, log);
|
|
247
|
+
registerDeprecatedFeatures(page, log);
|
|
248
|
+
registerSaveLoginExpiredistener(page, log);
|
|
249
|
+
|
|
250
|
+
log("Waiting for progress dialog to disapear");
|
|
251
|
+
await progressDialog.waitFor({
|
|
252
|
+
state: "detached",
|
|
253
|
+
timeout: 0,
|
|
254
|
+
});
|
|
255
|
+
log("Got progress dialog to disapear");
|
|
256
|
+
clearTimeout(progressInterval);
|
|
257
|
+
|
|
258
|
+
await page.getByRole("button", { name: "Menu" }).click();
|
|
259
|
+
await page.getByRole("menuitem", { name: "Project" }).click();
|
|
260
|
+
await page.getByRole("menuitem", { name: "Export" }).click();
|
|
261
|
+
log('"Export" clicked');
|
|
262
|
+
await page
|
|
263
|
+
.locator("ui-iconviewitem")
|
|
264
|
+
.filter({ hasText: "Web (HTML5)" })
|
|
265
|
+
.locator("ui-icon")
|
|
266
|
+
.click();
|
|
267
|
+
log('"Web" clicked');
|
|
268
|
+
|
|
269
|
+
await page.locator("#exportSelectPlatformDialog").getByRole("button", { name: "Next" }).click();
|
|
270
|
+
|
|
271
|
+
await page.getByLabel("Offline support").uncheck();
|
|
272
|
+
log("Disabled offline support");
|
|
273
|
+
|
|
274
|
+
await page.locator("#exportStandardOptionsDialog").getByRole("button", { name: "Next" }).click();
|
|
275
|
+
log('"Next" clicked');
|
|
276
|
+
const downloadPromise = page.waitForEvent("download");
|
|
277
|
+
await page.locator(".downloadExportedProject").click();
|
|
278
|
+
const download = await downloadPromise;
|
|
279
|
+
await page.getByRole("button", { name: "OK" }).click();
|
|
280
|
+
log('"Download" clicked');
|
|
281
|
+
|
|
282
|
+
const finalPath = join(downloadDir, download.suggestedFilename());
|
|
283
|
+
await download.saveAs(finalPath);
|
|
284
|
+
log("File Downloaded");
|
|
285
|
+
|
|
286
|
+
await page.close();
|
|
287
|
+
return finalPath;
|
|
288
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module "*.webp";
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ExtractInputsFromAction,
|
|
3
|
+
createAction,
|
|
4
|
+
createActionRunner,
|
|
5
|
+
createPathParam,
|
|
6
|
+
fileExists,
|
|
7
|
+
} from "@pipelab/plugin-core";
|
|
8
|
+
import { exportc3p, sharedParams } from "./export-shared.js";
|
|
9
|
+
|
|
10
|
+
export const ID = "export-construct-project";
|
|
11
|
+
|
|
12
|
+
export const exportAction = createAction({
|
|
13
|
+
id: ID,
|
|
14
|
+
name: "Export .c3p",
|
|
15
|
+
displayString:
|
|
16
|
+
"`Export project ${fmt.param(params.file, 'primary', 'No path selected')} with version ${params.version ? params.version : 'stable'}`",
|
|
17
|
+
meta: {},
|
|
18
|
+
params: {
|
|
19
|
+
file: createPathParam("", {
|
|
20
|
+
label: "File (.c3p)",
|
|
21
|
+
required: true,
|
|
22
|
+
control: {
|
|
23
|
+
type: "path",
|
|
24
|
+
label: "Pick a file (.c3p)",
|
|
25
|
+
options: {
|
|
26
|
+
properties: ["openFile"],
|
|
27
|
+
filters: [{ name: "Construct Project", extensions: ["c3p"] }],
|
|
28
|
+
title: "aaaa",
|
|
29
|
+
message: "bbbb",
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
...sharedParams,
|
|
34
|
+
},
|
|
35
|
+
outputs: {
|
|
36
|
+
folder: {
|
|
37
|
+
type: "path",
|
|
38
|
+
deprecated: true,
|
|
39
|
+
value: undefined as undefined | string,
|
|
40
|
+
label: "Exported zip",
|
|
41
|
+
// schema: schema.string()
|
|
42
|
+
},
|
|
43
|
+
parentFolder: {
|
|
44
|
+
type: "path",
|
|
45
|
+
deprecated: false,
|
|
46
|
+
value: undefined as undefined | string,
|
|
47
|
+
label: "Path to parent folder of exported zip",
|
|
48
|
+
// schema: schema.string()
|
|
49
|
+
},
|
|
50
|
+
zipFile: {
|
|
51
|
+
type: "path",
|
|
52
|
+
deprecated: false,
|
|
53
|
+
value: undefined as undefined | string,
|
|
54
|
+
label: "Exported zip",
|
|
55
|
+
// schema: schema.string()
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
description: "Export construct project from .c3p file",
|
|
59
|
+
icon: "",
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export const ExportActionRunner = createActionRunner<typeof exportAction>(async (options) => {
|
|
63
|
+
const file = options.inputs.file;
|
|
64
|
+
|
|
65
|
+
const c3pFileExists = await fileExists(file);
|
|
66
|
+
|
|
67
|
+
if (!c3pFileExists) {
|
|
68
|
+
throw new Error("You must specify a valid .c3p file");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
await exportc3p(file, options);
|
|
72
|
+
options.log("exportc3p done");
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export type Params = ExtractInputsFromAction<typeof exportAction>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import {
|
|
3
|
+
ExtractInputsFromAction,
|
|
4
|
+
createAction,
|
|
5
|
+
createActionRunner,
|
|
6
|
+
createPathParam,
|
|
7
|
+
fileExists,
|
|
8
|
+
} from "@pipelab/plugin-core";
|
|
9
|
+
import { exportc3p, sharedParams } from "./export-shared.js";
|
|
10
|
+
import { throttle } from "es-toolkit";
|
|
11
|
+
import { zipFolder } from "@pipelab/plugin-core";
|
|
12
|
+
|
|
13
|
+
export const ID = "export-construct-project-folder";
|
|
14
|
+
|
|
15
|
+
export const exportProjectAction = createAction({
|
|
16
|
+
id: ID,
|
|
17
|
+
name: "Export folder",
|
|
18
|
+
displayString: "`Export project ${params.version ? `r${params.version}` : ''}`",
|
|
19
|
+
meta: {},
|
|
20
|
+
params: {
|
|
21
|
+
folder: createPathParam("", {
|
|
22
|
+
required: true,
|
|
23
|
+
label: "Folder",
|
|
24
|
+
control: {
|
|
25
|
+
type: "path",
|
|
26
|
+
options: {
|
|
27
|
+
properties: ["openDirectory"],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
...sharedParams,
|
|
32
|
+
},
|
|
33
|
+
outputs: {
|
|
34
|
+
folder: {
|
|
35
|
+
type: "path",
|
|
36
|
+
deprecated: true,
|
|
37
|
+
value: undefined as undefined | string,
|
|
38
|
+
label: "Exported zip",
|
|
39
|
+
// schema: schema.string()
|
|
40
|
+
},
|
|
41
|
+
parentFolder: {
|
|
42
|
+
type: "path",
|
|
43
|
+
deprecated: false,
|
|
44
|
+
value: undefined as undefined | string,
|
|
45
|
+
label: "Path to parent folder of exported zip",
|
|
46
|
+
// schema: schema.string()
|
|
47
|
+
},
|
|
48
|
+
zipFile: {
|
|
49
|
+
type: "path",
|
|
50
|
+
deprecated: false,
|
|
51
|
+
value: undefined as undefined | string,
|
|
52
|
+
label: "Exported zip",
|
|
53
|
+
// schema: schema.string()
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
description: "Export construct project from folder",
|
|
57
|
+
icon: "",
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export const ExportProjectActionRunner = createActionRunner<typeof exportProjectAction>(
|
|
61
|
+
async (options) => {
|
|
62
|
+
const c3pFolderExists = await fileExists(options.inputs.folder);
|
|
63
|
+
if (!c3pFolderExists) {
|
|
64
|
+
throw new Error("You must specify a valid construct project folder");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const outputPath = join(options.cwd, "c3_tmp_proj.c3p");
|
|
68
|
+
|
|
69
|
+
const to = await zipFolder(options.inputs.folder, outputPath, options.log);
|
|
70
|
+
|
|
71
|
+
await exportc3p(to, options);
|
|
72
|
+
},
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
export type Params = ExtractInputsFromAction<typeof exportProjectAction>;
|