Skip to content

Commit

Permalink
WIP005
Browse files Browse the repository at this point in the history
  • Loading branch information
dakotablair committed Jun 27, 2024
1 parent c47e7b1 commit 0ef22d4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion scripts/build_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

HASH=$(git rev-parse HEAD) \
TAG=$(git describe --tags) \
scripts/build_deploy.ts
node_modules/.bin/ts-node scripts/build_deploy.ts
33 changes: 19 additions & 14 deletions scripts/build_deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
/* eslint-disable @typescript-eslint/no-var-requires */

const { spawn } = require('node:child_process');

Check failure on line 6 in scripts/build_deploy.ts

View workflow job for this annotation

GitHub Actions / build-main-open / build-push-image

'build_deploy.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
const promises = require('node:fs/promises');
const path = require('node:path');

const config = require('../config.json');

Expand Down Expand Up @@ -39,10 +41,10 @@ const build = (
publicURL,
backupCookie,
});
let count = 0;
const build_path = `./deploy/${environment}`;
const buildPath = `./deploy/${environment}`;
const buildDate = new Date().toISOString();
const envsNew: Envs = {
BUILD_PATH: build_path,
BUILD_PATH: buildPath,
PUBLIC_URL: publicURL,
REACT_APP_KBASE_ENV: environment,
REACT_APP_KBASE_DOMAIN: domain,
Expand All @@ -51,22 +53,26 @@ const build = (
};

Object.assign(process.env, envsNew);
// const proc = spawn('npm', ['run', 'build'], { timeout: 60000 });
const proc = spawn('echo', ['npm', 'run', 'build'], { timeout: 60000 });
proc.stdout.on('data', (data: string) => {
// eslint-disable-next-line no-console
console.log({ count, stdout: `${data}` });
count += 1;
const proc = spawn('npm', ['run', 'build'], { timeout: 60000 });
proc.stdout.on('data', (data: Buffer) => {
console.log(data.toString()); // eslint-disable-line no-console
});

proc.on('close', (code: number) => {
const artifact = {
proc.on('close', async (code: number) => {
const build = {
date: buildDate,
name: 'Europa',
environment,
hash,
name: 'Europa',
tag,
};
console.log({ artifact, code }); // eslint-disable-line no-console
let filehandle;
try {
filehandle = await promises.open(path.join(buildPath, 'build.json'), 'w');
await filehandle.write(JSON.stringify(build));
} finally {
await filehandle?.close();
}
});
};

Expand All @@ -75,7 +81,6 @@ const main = () => {
const hash = process.env.HASH || '';
const tag = process.env.TAG || '';
Object.keys(envs).forEach((env) => {
// console.log({ env, data: envs[env] }); // eslint-disable-line no-console
build(env, hash, tag, envs[env]);
});
build('nodetest', hash, tag, config.environments.ci);
Expand Down

0 comments on commit 0ef22d4

Please sign in to comment.