mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-21 16:00:59 -05:00
Added strip
script
This commit is contained in:
parent
1e6391f5b5
commit
4823b4cc14
2 changed files with 59 additions and 0 deletions
|
@ -7,8 +7,10 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"clean": "rimraf dist",
|
"clean": "rimraf dist",
|
||||||
"generate": "ncc run scripts/generate.ts -t",
|
"generate": "ncc run scripts/generate.ts -t",
|
||||||
|
"strip": "ncc run scripts/strip.ts -t",
|
||||||
"prebuild": "npm run clean && npm run generate",
|
"prebuild": "npm run clean && npm run generate",
|
||||||
"build": "ncc build -m -s --license license.txt",
|
"build": "ncc build -m -s --license license.txt",
|
||||||
|
"postbuild": "npm run strip",
|
||||||
"test:lint": "eslint \"@(src|scripts)/**/*.ts\" && eslint --rule \"no-invalid-this: off\" tests/**/*.ts",
|
"test:lint": "eslint \"@(src|scripts)/**/*.ts\" && eslint --rule \"no-invalid-this: off\" tests/**/*.ts",
|
||||||
"test:unit": "jest --testPathPattern=unit --watchAll=false",
|
"test:unit": "jest --testPathPattern=unit --watchAll=false",
|
||||||
"test:integration": "jest --testPathPattern=integration --watchAll=false --passWithNoTests",
|
"test:integration": "jest --testPathPattern=integration --watchAll=false --passWithNoTests",
|
||||||
|
|
57
scripts/strip.ts
Normal file
57
scripts/strip.ts
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* POSTBUILD SCRIPT */
|
||||||
|
/* */
|
||||||
|
/* This script performs the following operations: */
|
||||||
|
/* 1. Strips action metadata file from custom fields */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
import { stripActionMetadataFileFromCustomFields } from "@/utils/actions";
|
||||||
|
import { WINDOWS_NEWLINE } from "@/utils/environment";
|
||||||
|
import { FileNotFoundError } from "@/utils/errors";
|
||||||
|
import { basename } from "node:path";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path to the action metadata template file.
|
||||||
|
*/
|
||||||
|
const ACTION_METADATA_TEMPLATE_FILE = "./action.template.yml";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path to the processed action metadata file.
|
||||||
|
*/
|
||||||
|
const ACTION_METADATA_FILE = "./action.yml";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processing options.
|
||||||
|
*/
|
||||||
|
const OPTIONS: PostbuildOptions = {
|
||||||
|
// The name of the source file everything else is generated from.
|
||||||
|
sourceFileName: basename(ACTION_METADATA_TEMPLATE_FILE),
|
||||||
|
|
||||||
|
// The encoding used for reading and writing files.
|
||||||
|
encoding: "utf8",
|
||||||
|
|
||||||
|
// Add a warning message about auto-generated files
|
||||||
|
generateAutoGeneratedWarningMessage: true,
|
||||||
|
|
||||||
|
// Remove fields that are only used in the template from the generated files.
|
||||||
|
removeTemplateOnlyFields: true,
|
||||||
|
|
||||||
|
// The newline character(s) to use in the generated files.
|
||||||
|
newline: WINDOWS_NEWLINE,
|
||||||
|
|
||||||
|
// The maximum line width for the generated files.
|
||||||
|
lineWidth: 80,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processing options' type.
|
||||||
|
*/
|
||||||
|
type PostbuildOptions = Exclude<
|
||||||
|
& Parameters<typeof stripActionMetadataFileFromCustomFields>[2]
|
||||||
|
, string>;
|
||||||
|
|
||||||
|
// Ensure the action metadata file exists
|
||||||
|
FileNotFoundError.throwIfNotFound(ACTION_METADATA_FILE);
|
||||||
|
|
||||||
|
// Strip the action metadata file
|
||||||
|
await stripActionMetadataFileFromCustomFields(ACTION_METADATA_FILE, ACTION_METADATA_FILE, OPTIONS);
|
Loading…
Reference in a new issue