Skip to content

Commit a9ab3c5

Browse files
Merge branch 'GoodBoyNinja-master'
2 parents 133ef6d + bbdaeb8 commit a9ab3c5

4 files changed

Lines changed: 804 additions & 1795 deletions

File tree

vite-cep-plugin/src/index.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ interface CepOptions {
129129
debugReact: boolean;
130130
isServe: boolean;
131131
cepDist: string;
132-
zxpDir: string;
133-
zipDir: string;
132+
zxpOutput: string;
133+
zipOutput: string;
134134
packages: string[];
135135
}
136136
export const cep = (opts: CepOptions) => {
@@ -143,8 +143,8 @@ export const cep = (opts: CepOptions) => {
143143
isServe,
144144
debugReact,
145145
cepDist,
146-
zxpDir,
147-
zipDir,
146+
zxpOutput,
147+
zipOutput,
148148
packages,
149149
} = opts;
150150

@@ -333,11 +333,13 @@ export const cep = (opts: CepOptions) => {
333333
const input = path.join(dir, cepDist);
334334
await removeZeroByteFiles(input);
335335
if (isPackage) {
336-
const zxpPath = await signZXP(cepConfig, input, zxpDir, tmpDir);
336+
const zxpPath = await signZXP(cepConfig, input, zxpOutput, tmpDir);
337337
if (isMetaPackage) {
338-
const name = `${cepConfig.displayName}_${cepConfig.version}`;
338+
const zipName = path.basename(opts.zipOutput)
339+
const zipDir = path.dirname(opts.zipOutput)
340+
const zxpDir = path.dirname(zxpPath);
339341
await zipPackage(
340-
name,
342+
zipName,
341343
zipDir,
342344
zxpDir,
343345
cepConfig.copyZipAssets,
@@ -613,7 +615,7 @@ export const runAction = (opts: CepOptions, action: string) => {
613615
isServe,
614616
debugReact,
615617
cepDist,
616-
zxpDir,
618+
zxpOutput,
617619
packages,
618620
} = opts;
619621

vite-cep-plugin/src/lib/zxp.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ import { existsSync, readdirSync } from "fs";
1111
export const signZXP = async (
1212
config: CEP_Config,
1313
input: string,
14-
zxpDir: string,
14+
zxpFile: string,
1515
tmpDir: string,
1616
) => {
1717
const zxpCmd = os.platform() == "win32" ? `ZXPSignCmd` : `./ZXPSignCmd`;
18+
zxpFile = zxpFile + ".zxp";
1819

1920
if (os.platform() === "darwin") {
2021
const zxpsignCmdPath = path.join(__dirname, "..", "bin", "ZXPSignCmd");
@@ -29,13 +30,13 @@ export const signZXP = async (
2930

3031
const name = config.id;
3132
const data = config.zxp;
32-
const output = path.join(zxpDir, `${name}.zxp`);
33+
const zxpDir = path.dirname(zxpFile);
3334
const certPath = path.join(tmpDir, `${name}-cert.p12`);
3435
const signPrepStr = `${zxpCmd} -selfSignedCert ${data.country} ${data.province} ${data.org} ${name} ${data.password} "${certPath}"`;
3536
const cwdDir = path.join(__dirname, "..", "bin");
3637

3738
removeIfExists(certPath);
38-
removeIfExists(output);
39+
removeIfExists(zxpFile);
3940
safeCreate(zxpDir);
4041
console.log({ signPrepStr });
4142
execSync(signPrepStr, { cwd: cwdDir, encoding: "utf-8" });
@@ -47,7 +48,7 @@ export const signZXP = async (
4748
await pause(100);
4849
}
4950

50-
let signStr = `${zxpCmd} -sign "${input}" "${output}" "${certPath}" ${data.password}`;
51+
let signStr = `${zxpCmd} -sign "${input}" "${zxpFile}" "${certPath}" ${data.password}`;
5152

5253
let numTSAs = 0;
5354
if (data.tsa) {
@@ -95,6 +96,6 @@ export const signZXP = async (
9596
}
9697
}
9798

98-
log("built zxp", true, output);
99-
return output;
99+
log("built zxp", true, zxpFile);
100+
return zxpFile;
100101
};

vite.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import vue from "@vitejs/plugin-vue"; // BOLT_VUE_ONLY
55
import { svelte } from "@sveltejs/vite-plugin-svelte"; // BOLT_SVELTE_ONLY
66
// import sveltePreprocess from "svelte-preprocess"; // BOLT_SVELTE_ONLY
77

8-
import { cep, runAction } from "vite-cep-plugin";
8+
import { cep, CepOptions, runAction } from "vite-cep-plugin";
99
import cepConfig from "./cep.config";
1010
import path from "path";
1111
import { extendscriptConfig } from "./vite.es.config";
@@ -26,12 +26,12 @@ const isPackage = process.env.ZXP_PACKAGE === "true" || isMetaPackage;
2626
const isServe = process.env.SERVE_PANEL === "true";
2727
const action = process.env.BOLT_ACTION;
2828

29-
let input = {};
29+
let input: { [key: string]: string } = {};
3030
cepConfig.panels.map((panel) => {
3131
input[panel.name] = path.resolve(root, panel.mainPath);
3232
});
3333

34-
const config = {
34+
const config: CepOptions = {
3535
cepConfig,
3636
isProduction,
3737
isPackage,
@@ -40,8 +40,8 @@ const config = {
4040
debugReact,
4141
dir: `${__dirname}/${devDist}`,
4242
cepDist: cepDist,
43-
zxpDir: `${__dirname}/${devDist}/zxp`,
44-
zipDir: `${__dirname}/${devDist}/zip`,
43+
zxpOutput: `${__dirname}/${devDist}/zxp/${cepConfig.id}`,
44+
zipOutput: `${__dirname}/${devDist}/zip/${cepConfig.displayName}_${cepConfig.version}`,
4545
packages: cepConfig.installModules || [],
4646
};
4747

0 commit comments

Comments
 (0)