chore: reinstate exec signature
parent
931dff7df8
commit
9772480122
|
|
@ -60,6 +60,8 @@
|
||||||
// Allow Array.from(set) mitigate TS2569 which would require '--downlevelIteration'
|
// Allow Array.from(set) mitigate TS2569 which would require '--downlevelIteration'
|
||||||
"unicorn/prefer-spread": "off",
|
"unicorn/prefer-spread": "off",
|
||||||
// Deno has dependencies file, this rule enforces it's named re-exports
|
// Deno has dependencies file, this rule enforces it's named re-exports
|
||||||
"unicorn/prevent-abbreviations": "off"
|
"unicorn/prevent-abbreviations": "off",
|
||||||
|
// Allow disabling eslint per file
|
||||||
|
"eslint-comments/no-use": "off"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import * as assert from 'https://deno.land/std@0.144.0/testing/asserts.ts';
|
||||||
import * as aws from 'https://deno.land/x/aws_api/client/mod.ts';
|
import * as aws from 'https://deno.land/x/aws_api/client/mod.ts';
|
||||||
import * as base64 from 'https://deno.land/std@0.145.0/encoding/base64.ts';
|
import * as base64 from 'https://deno.land/std@0.145.0/encoding/base64.ts';
|
||||||
import * as compress from 'https://deno.land/x/compress@v0.3.3/mod.ts';
|
import * as compress from 'https://deno.land/x/compress@v0.3.3/mod.ts';
|
||||||
// import * as core from 'https://deno.land/x/deno_actions_core@0.1.3/mod.ts';
|
|
||||||
import * as fs from 'https://deno.land/std@0.142.0/node/fs/promises.ts';
|
import * as fs from 'https://deno.land/std@0.142.0/node/fs/promises.ts';
|
||||||
import * as fsSync from 'https://deno.land/std@0.142.0/fs/mod.ts';
|
import * as fsSync from 'https://deno.land/std@0.142.0/fs/mod.ts';
|
||||||
import * as k8s from 'https://deno.land/x/kubernetes_client/mod.ts';
|
import * as k8s from 'https://deno.land/x/kubernetes_client/mod.ts';
|
||||||
|
|
@ -12,37 +11,15 @@ import * as nanoid from 'https://deno.land/x/nanoid@v3.0.0/mod.ts';
|
||||||
import * as path from 'https://deno.land/std@0.142.0/path/mod.ts';
|
import * as path from 'https://deno.land/std@0.142.0/path/mod.ts';
|
||||||
import * as process from 'https://deno.land/std@0.104.0/node/process.ts';
|
import * as process from 'https://deno.land/std@0.104.0/node/process.ts';
|
||||||
import * as semver from 'https://deno.land/x/semver@v1.4.0/mod.ts';
|
import * as semver from 'https://deno.land/x/semver@v1.4.0/mod.ts';
|
||||||
import * as waitUntil from './helpers/waitUntil.ts';
|
|
||||||
import * as yaml from 'https://deno.land/std@0.145.0/encoding/yaml.ts';
|
import * as yaml from 'https://deno.land/std@0.145.0/encoding/yaml.ts';
|
||||||
import { crypto } from 'https://deno.land/std@0.142.0/crypto/mod.ts';
|
import { crypto } from 'https://deno.land/std@0.142.0/crypto/mod.ts';
|
||||||
import { v4 as uuid } from 'https://deno.land/std@0.142.0/uuid/mod.ts';
|
import { v4 as uuid } from 'https://deno.land/std@0.142.0/uuid/mod.ts';
|
||||||
import * as http from 'https://deno.land/std@0.145.0/node/http.ts';
|
import * as http from 'https://deno.land/std@0.145.0/node/http.ts';
|
||||||
import { Command } from 'https://deno.land/x/cmd@v1.2.0/commander/index.ts';
|
import { Command } from 'https://deno.land/x/cmd@v1.2.0/commander/index.ts';
|
||||||
|
|
||||||
const core = {
|
// Internally managed
|
||||||
info: console.log,
|
import waitUntil from './modules/wait-until.ts';
|
||||||
error: (error) => console.error(error, error.stack),
|
import { core, exec } from './modules/actions/index.ts';
|
||||||
setFailed: (failure) => console.error('setFailed:', failure),
|
|
||||||
|
|
||||||
// Adapted from: https://github.com/actions/toolkit/blob/9b7bcb1567c9b7f134eb3c2d6bbf409a5106a956/packages/core/src/core.ts#L128
|
|
||||||
getInput: (name, options) => {
|
|
||||||
const val: string = Deno.env.get(`INPUT_${name.replace(/ /g, '_').toUpperCase()}`) || '';
|
|
||||||
|
|
||||||
if (options?.required && !val) {
|
|
||||||
throw new Error(`Input required and not supplied: ${name}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options && options.trimWhitespace === false) {
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
return val.trim();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const exec = () => {
|
|
||||||
throw new Error('exec is not implemented'); // @actions/exec'
|
|
||||||
};
|
|
||||||
|
|
||||||
const getUnityChangeSet = () => {
|
const getUnityChangeSet = () => {
|
||||||
throw new Error('getUnityChangeSet is not implemented'); // unity-changeset'
|
throw new Error('getUnityChangeSet is not implemented'); // unity-changeset'
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ class SetupMac {
|
||||||
if (!fs.existsSync(this.unityHubPath)) {
|
if (!fs.existsSync(this.unityHubPath)) {
|
||||||
// Ignoring return code because the log seems to overflow the internal buffer which triggers
|
// Ignoring return code because the log seems to overflow the internal buffer which triggers
|
||||||
// a false error
|
// a false error
|
||||||
const errorCode = await exec(command, undefined, { silent, ignoreReturnCode: true });
|
const { exitCode } = await exec(command, undefined, { silent, ignoreReturnCode: true });
|
||||||
if (errorCode) {
|
if (exitCode) {
|
||||||
throw new Error(`There was an error installing the Unity Editor. See logs above for details.`);
|
throw new Error(`There was an error installing the Unity Editor. See logs above for details.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -38,8 +38,8 @@ class SetupMac {
|
||||||
|
|
||||||
// Ignoring return code because the log seems to overflow the internal buffer which triggers
|
// Ignoring return code because the log seems to overflow the internal buffer which triggers
|
||||||
// a false error
|
// a false error
|
||||||
const errorCode = await exec(command, undefined, { silent, ignoreReturnCode: true });
|
const { exitCode } = await exec(command, undefined, { silent, ignoreReturnCode: true });
|
||||||
if (errorCode) {
|
if (exitCode) {
|
||||||
throw new Error(`There was an error installing the Unity Editor. See logs above for details.`);
|
throw new Error(`There was an error installing the Unity Editor. See logs above for details.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class System {
|
||||||
throw new Error(`Failed to execute empty command`);
|
throw new Error(`Failed to execute empty command`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const exitCode = await exec(command, arguments_, { silent: true, listeners, ...options });
|
const { exitCode } = await exec(command, arguments_, { silent: true, listeners, ...options });
|
||||||
showOutput();
|
showOutput();
|
||||||
if (exitCode !== 0) {
|
if (exitCode !== 0) {
|
||||||
throwContextualError(`Command returned non-zero exit code.\nError: ${error}`);
|
throwContextualError(`Command returned non-zero exit code.\nError: ${error}`);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
|
export const core = {
|
||||||
|
info: console.log,
|
||||||
|
|
||||||
|
warning: console.warn,
|
||||||
|
|
||||||
|
error: (error) => {
|
||||||
|
console.error(error, error.stack);
|
||||||
|
},
|
||||||
|
|
||||||
|
setFailed: (failure) => {
|
||||||
|
console.error('setFailed:', failure);
|
||||||
|
Deno.exit(1);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Adapted from: https://github.com/actions/toolkit/blob/9b7bcb1567c9b7f134eb3c2d6bbf409a5106a956/packages/core/src/core.ts#L128
|
||||||
|
getInput: (name, options) => {
|
||||||
|
const variable = `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
||||||
|
const value: string = Deno.env.get(variable) || '';
|
||||||
|
|
||||||
|
if (options?.required && !value) {
|
||||||
|
throw new Error(`Input required and not supplied: ${name}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options?.trimWhitespace === false) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value.trim();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
import { exec as originalExec } from 'https://deno.land/x/exec/mod.ts';
|
||||||
|
import { core } from './core.ts';
|
||||||
|
|
||||||
|
export enum OutputMode {
|
||||||
|
None = 0, // no output, just run the command
|
||||||
|
StdOut, // dump the output to stdout
|
||||||
|
Capture, // capture the output and return it
|
||||||
|
Tee, // both dump and capture the output
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IExecResponse {
|
||||||
|
code: number;
|
||||||
|
success: boolean;
|
||||||
|
output: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IOptions {
|
||||||
|
output?: OutputMode;
|
||||||
|
verbose?: boolean;
|
||||||
|
continueOnError?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Todo - change signature of exec inside the code instead of adapting the exec method
|
||||||
|
const exec = async (command, args: string | string[] = [], ghActionsOptions: IOptions = {}): Promise<IExecResponse> => {
|
||||||
|
core.info('Running command: ', command, args);
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
output: OutputMode.Tee,
|
||||||
|
verbose: false,
|
||||||
|
continueOnError: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
const { silent = false, ignoreReturnCode } = ghActionsOptions;
|
||||||
|
if (silent) options.output = OutputMode.None;
|
||||||
|
if (ignoreReturnCode) options.continueOnError = true;
|
||||||
|
|
||||||
|
const result = await originalExec(`${command} ${args.join(' ')}`, options);
|
||||||
|
core.info('result:', result);
|
||||||
|
|
||||||
|
const { status = {}, output = '' } = result;
|
||||||
|
const { code: exitCode, success } = status;
|
||||||
|
|
||||||
|
return { exitCode, success, output };
|
||||||
|
};
|
||||||
|
|
||||||
|
export { exec };
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
/**
|
||||||
|
* The actions/core package from GitHub errors out.
|
||||||
|
* This substitutes the parts we use in a Deno-compatible way.
|
||||||
|
*/
|
||||||
|
export { core } from './core.ts';
|
||||||
|
export { exec } from './exec.ts';
|
||||||
Loading…
Reference in New Issue