Fix addon build
This commit is contained in:
parent
a8dd53507d
commit
589010493d
1 changed files with 23 additions and 9 deletions
|
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
import { promises as fs } from "fs";
|
import { promises as fs } from "fs";
|
||||||
import { promisify } from "util";
|
import { glob } from "glob";
|
||||||
import glob from "glob";
|
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import os from "os";
|
import os from "os";
|
||||||
|
|
||||||
|
|
@ -12,7 +11,10 @@ const packageFile = async (actualPath: string): Promise<any> => {
|
||||||
const data = await fs.readFile(actualPath, "utf-8");
|
const data = await fs.readFile(actualPath, "utf-8");
|
||||||
const content = Buffer.from(data, "utf-8").toString("base64");
|
const content = Buffer.from(data, "utf-8").toString("base64");
|
||||||
const fileStats = await fs.stat(actualPath);
|
const fileStats = await fs.stat(actualPath);
|
||||||
const permission = parseInt((fileStats.mode & 0o777).toString(8).slice(-3), 10);
|
const permission = parseInt(
|
||||||
|
(fileStats.mode & 0o777).toString(8).slice(-3),
|
||||||
|
10,
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
location: packagePath,
|
location: packagePath,
|
||||||
permission,
|
permission,
|
||||||
|
|
@ -23,7 +25,12 @@ const packageFile = async (actualPath: string): Promise<any> => {
|
||||||
|
|
||||||
const packageFiles = async () => {
|
const packageFiles = async () => {
|
||||||
const packagedFiles: any[] = [];
|
const packagedFiles: any[] = [];
|
||||||
const ignoredPatterns = [/\.gitkeep/, /Gemfile/, /Gemfile.lock/, /\.ruby-version/];
|
const ignoredPatterns = [
|
||||||
|
/\.gitkeep/,
|
||||||
|
/Gemfile/,
|
||||||
|
/Gemfile.lock/,
|
||||||
|
/\.ruby-version/,
|
||||||
|
];
|
||||||
|
|
||||||
const processDir = async (dir: string) => {
|
const processDir = async (dir: string) => {
|
||||||
const entries = await fs.readdir(dir, { withFileTypes: true });
|
const entries = await fs.readdir(dir, { withFileTypes: true });
|
||||||
|
|
@ -43,7 +50,11 @@ const packageFiles = async () => {
|
||||||
return packagedFiles;
|
return packagedFiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createZPM = async ({ name, displayName, version }: Record<string, string>) => {
|
export const createZPM = async ({
|
||||||
|
name,
|
||||||
|
displayName,
|
||||||
|
version,
|
||||||
|
}: Record<string, string>) => {
|
||||||
const files = await packageFiles();
|
const files = await packageFiles();
|
||||||
const skeleton = {
|
const skeleton = {
|
||||||
name: displayName,
|
name: displayName,
|
||||||
|
|
@ -53,14 +64,13 @@ export const createZPM = async ({ name, displayName, version }: Record<string, s
|
||||||
url: `https://gitlab.com/digiresilience/link/link-stack/packages/${name}`,
|
url: `https://gitlab.com/digiresilience/link/link-stack/packages/${name}`,
|
||||||
buildhost: os.hostname(),
|
buildhost: os.hostname(),
|
||||||
builddate: new Date().toISOString(),
|
builddate: new Date().toISOString(),
|
||||||
files
|
files,
|
||||||
};
|
};
|
||||||
const pkg = JSON.stringify(skeleton, null, 2);
|
const pkg = JSON.stringify(skeleton, null, 2);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const gs = promisify(glob);
|
const files = await glob(`../../docker/zammad/addons/${name}-v*.zpm`, {});
|
||||||
const files = await gs(`../../docker/zammad/addons/${name}-v*.zpm`);
|
|
||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
await fs.unlink(file);
|
await fs.unlink(file);
|
||||||
|
|
@ -69,7 +79,11 @@ export const createZPM = async ({ name, displayName, version }: Record<string, s
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
await fs.writeFile(`../../docker/zammad/addons/${name}-v${version}.zpm`, pkg, 'utf-8');
|
await fs.writeFile(
|
||||||
|
`../../docker/zammad/addons/${name}-v${version}.zpm`,
|
||||||
|
pkg,
|
||||||
|
"utf-8",
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue