mirror of
https://github.com/garronej/ts-ci.git
synced 2025-11-30 21:43:05 +00:00
Add remove_dark_mode_specific_images_from_readme
This commit is contained in:
parent
f413caaaac
commit
4b7615d6bc
6 changed files with 178 additions and 12 deletions
|
|
@ -4,7 +4,7 @@ author: 'u/garronej'
|
||||||
inputs:
|
inputs:
|
||||||
action_name:
|
action_name:
|
||||||
required: true
|
required: true
|
||||||
description: 'Action to run, one of: "get_package_json_version", "dispatch_event", "update_changelog", "sync_package_and_package_lock_version", "setup_repo_webhook_for_deno_land_publishing", "is_well_formed_and_available_module_name", "string_replace", "tell_if_project_uses_npm_or_yarn", "is_package_json_version_upgraded"'
|
description: 'Action to run, one of: "get_package_json_version", "dispatch_event", "update_changelog", "sync_package_and_package_lock_version", "setup_repo_webhook_for_deno_land_publishing", "is_well_formed_and_available_module_name", "string_replace", "tell_if_project_uses_npm_or_yarn", "is_package_json_version_upgraded", "remove_dark_mode_specific_images_from_readme"'
|
||||||
owner:
|
owner:
|
||||||
required: false
|
required: false
|
||||||
description: 'Repository owner, example: ''garronej'',github.repository_owner'
|
description: 'Repository owner, example: ''garronej'',github.repository_owner'
|
||||||
|
|
|
||||||
65
dist/index.js
vendored
65
dist/index.js
vendored
|
|
@ -1783,10 +1783,12 @@ const sync_package_and_package_lock_version = __importStar(__webpack_require__(8
|
||||||
const setup_repo_webhook_for_deno_land_publishing = __importStar(__webpack_require__(518));
|
const setup_repo_webhook_for_deno_land_publishing = __importStar(__webpack_require__(518));
|
||||||
const is_well_formed_and_available_module_name = __importStar(__webpack_require__(245));
|
const is_well_formed_and_available_module_name = __importStar(__webpack_require__(245));
|
||||||
const tell_if_project_uses_npm_or_yarn = __importStar(__webpack_require__(201));
|
const tell_if_project_uses_npm_or_yarn = __importStar(__webpack_require__(201));
|
||||||
|
const remove_dark_mode_specific_images_from_readme = __importStar(__webpack_require__(275));
|
||||||
const string_replace = __importStar(__webpack_require__(599));
|
const string_replace = __importStar(__webpack_require__(599));
|
||||||
const is_package_json_version_upgraded = __importStar(__webpack_require__(949));
|
const is_package_json_version_upgraded = __importStar(__webpack_require__(949));
|
||||||
const inputHelper_1 = __webpack_require__(649);
|
const inputHelper_1 = __webpack_require__(649);
|
||||||
const update_changelog = __importStar(__webpack_require__(702));
|
const update_changelog = __importStar(__webpack_require__(702));
|
||||||
|
const assert_1 = __webpack_require__(606);
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const action_name = inputHelper_1.getActionName();
|
const action_name = inputHelper_1.getActionName();
|
||||||
|
|
@ -1818,10 +1820,11 @@ function run() {
|
||||||
case "is_package_json_version_upgraded":
|
case "is_package_json_version_upgraded":
|
||||||
is_package_json_version_upgraded.setOutput(yield is_package_json_version_upgraded.action(action_name, is_package_json_version_upgraded.getActionParams(), core));
|
is_package_json_version_upgraded.setOutput(yield is_package_json_version_upgraded.action(action_name, is_package_json_version_upgraded.getActionParams(), core));
|
||||||
return null;
|
return null;
|
||||||
|
case "remove_dark_mode_specific_images_from_readme":
|
||||||
|
yield remove_dark_mode_specific_images_from_readme.action(action_name);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
if (true) {
|
assert_1.assert(false);
|
||||||
throw new Error(`${action_name} Not supported by this toolkit`);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
(() => __awaiter(void 0, void 0, void 0, function* () {
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
|
@ -1829,7 +1832,7 @@ function run() {
|
||||||
yield run();
|
yield run();
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(String(error));
|
||||||
}
|
}
|
||||||
}))();
|
}))();
|
||||||
|
|
||||||
|
|
@ -2284,6 +2287,57 @@ exports.assertIsRefWrapper = {
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=assertIsRefWrapper.js.map
|
//# sourceMappingURL=assertIsRefWrapper.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 275:
|
||||||
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.removeDarkModeSpecificImageFromReadme = exports.action = void 0;
|
||||||
|
const fs = __importStar(__webpack_require__(747));
|
||||||
|
function action(_actionName) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
fs.writeFileSync("README.md", Buffer.from(removeDarkModeSpecificImageFromReadme(fs.readFileSync("README.md").toString("utf8")), "utf8"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.action = action;
|
||||||
|
function removeDarkModeSpecificImageFromReadme(readmeRawContent) {
|
||||||
|
return readmeRawContent
|
||||||
|
.replace(/^!\[[^\]]*\]\([^#]+#gh-dark-mode-only\)/gm, "");
|
||||||
|
}
|
||||||
|
exports.removeDarkModeSpecificImageFromReadme = removeDarkModeSpecificImageFromReadme;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 280:
|
/***/ 280:
|
||||||
|
|
@ -10747,7 +10801,8 @@ exports.availableActions = [
|
||||||
"is_well_formed_and_available_module_name",
|
"is_well_formed_and_available_module_name",
|
||||||
"string_replace",
|
"string_replace",
|
||||||
"tell_if_project_uses_npm_or_yarn",
|
"tell_if_project_uses_npm_or_yarn",
|
||||||
"is_package_json_version_upgraded"
|
"is_package_json_version_upgraded",
|
||||||
|
"remove_dark_mode_specific_images_from_readme"
|
||||||
];
|
];
|
||||||
function getInputDescription(inputName) {
|
function getInputDescription(inputName) {
|
||||||
switch (inputName) {
|
switch (inputName) {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,8 @@ export const availableActions = [
|
||||||
"is_well_formed_and_available_module_name",
|
"is_well_formed_and_available_module_name",
|
||||||
"string_replace",
|
"string_replace",
|
||||||
"tell_if_project_uses_npm_or_yarn",
|
"tell_if_project_uses_npm_or_yarn",
|
||||||
"is_package_json_version_upgraded"
|
"is_package_json_version_upgraded",
|
||||||
|
"remove_dark_mode_specific_images_from_readme"
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
15
src/main.ts
15
src/main.ts
|
|
@ -5,10 +5,13 @@ import * as sync_package_and_package_lock_version from "./sync_package_and_packa
|
||||||
import * as setup_repo_webhook_for_deno_land_publishing from "./setup_repo_webhook_for_deno_land_publishing";
|
import * as setup_repo_webhook_for_deno_land_publishing from "./setup_repo_webhook_for_deno_land_publishing";
|
||||||
import * as is_well_formed_and_available_module_name from "./is_well_formed_and_available_module_name";
|
import * as is_well_formed_and_available_module_name from "./is_well_formed_and_available_module_name";
|
||||||
import * as tell_if_project_uses_npm_or_yarn from "./tell_if_project_uses_npm_or_yarn";
|
import * as tell_if_project_uses_npm_or_yarn from "./tell_if_project_uses_npm_or_yarn";
|
||||||
|
import * as remove_dark_mode_specific_images_from_readme from "./remove_dark_mode_specific_images_from_readme";
|
||||||
import * as string_replace from "./string_replace";
|
import * as string_replace from "./string_replace";
|
||||||
import * as is_package_json_version_upgraded from "./is_package_json_version_upgraded";
|
import * as is_package_json_version_upgraded from "./is_package_json_version_upgraded";
|
||||||
import { getActionName } from "./inputHelper";
|
import { getActionName } from "./inputHelper";
|
||||||
import * as update_changelog from "./update_changelog";
|
import * as update_changelog from "./update_changelog";
|
||||||
|
import { assert } from "tsafe/assert";
|
||||||
|
import type { Equals } from "tsafe";
|
||||||
|
|
||||||
async function run(): Promise<null> {
|
async function run(): Promise<null> {
|
||||||
|
|
||||||
|
|
@ -90,12 +93,14 @@ async function run(): Promise<null> {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return null;
|
return null;
|
||||||
|
case "remove_dark_mode_specific_images_from_readme":
|
||||||
|
await remove_dark_mode_specific_images_from_readme.action(
|
||||||
|
action_name
|
||||||
|
);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (1 === 0 + 1) {
|
assert<Equals<typeof action_name, never>>(false);
|
||||||
throw new Error(`${action_name} Not supported by this toolkit`);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,7 +111,7 @@ async function run(): Promise<null> {
|
||||||
await run()
|
await run()
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(String(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
21
src/remove_dark_mode_specific_images_from_readme.ts
Normal file
21
src/remove_dark_mode_specific_images_from_readme.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
import * as fs from "fs";
|
||||||
|
|
||||||
|
export async function action(
|
||||||
|
_actionName: "remove_dark_mode_specific_images_from_readme"
|
||||||
|
) {
|
||||||
|
|
||||||
|
fs.writeFileSync("README.md",
|
||||||
|
Buffer.from(
|
||||||
|
removeDarkModeSpecificImageFromReadme(
|
||||||
|
fs.readFileSync("README.md").toString("utf8")
|
||||||
|
),
|
||||||
|
"utf8"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeDarkModeSpecificImageFromReadme(readmeRawContent: string) {
|
||||||
|
return readmeRawContent
|
||||||
|
.replace(/^!\[[^\]]*\]\([^#]+#gh-dark-mode-only\)/gm, "");
|
||||||
|
}
|
||||||
84
src/test/removeDarkModeSpecificImageFromReadme.ts
Normal file
84
src/test/removeDarkModeSpecificImageFromReadme.ts
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
|
||||||
|
import { assert } from "tsafe/assert";
|
||||||
|
import { removeDarkModeSpecificImageFromReadme } from "../remove_dark_mode_specific_images_from_readme";
|
||||||
|
|
||||||
|
const input = `
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<i>Type-safe internationalization and translation React library</i>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<a href="https://github.com/garronej/i18nifty/actions">
|
||||||
|
<img src="https://github.com/garronej/i18nifty/workflows/ci/badge.svg?branch=main">
|
||||||
|
</a>
|
||||||
|
<a href="https://bundlephobia.com/package/i18nifty">
|
||||||
|
<img src="https://img.shields.io/bundlephobia/minzip/i18nifty">
|
||||||
|
</a>
|
||||||
|
<a href="https://www.npmjs.com/package/i18nifty">
|
||||||
|
<img src="https://img.shields.io/npm/dm/i18nifty">
|
||||||
|
</a>
|
||||||
|
<a href="https://github.com/garronej/i18nifty/blob/main/LICENSE">
|
||||||
|
<img src="https://img.shields.io/npm/l/i18nifty">
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
`;
|
||||||
|
|
||||||
|
|
||||||
|
const expected = `
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<i>Type-safe internationalization and translation React library</i>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<a href="https://github.com/garronej/i18nifty/actions">
|
||||||
|
<img src="https://github.com/garronej/i18nifty/workflows/ci/badge.svg?branch=main">
|
||||||
|
</a>
|
||||||
|
<a href="https://bundlephobia.com/package/i18nifty">
|
||||||
|
<img src="https://img.shields.io/bundlephobia/minzip/i18nifty">
|
||||||
|
</a>
|
||||||
|
<a href="https://www.npmjs.com/package/i18nifty">
|
||||||
|
<img src="https://img.shields.io/npm/dm/i18nifty">
|
||||||
|
</a>
|
||||||
|
<a href="https://github.com/garronej/i18nifty/blob/main/LICENSE">
|
||||||
|
<img src="https://img.shields.io/npm/l/i18nifty">
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
`;
|
||||||
|
|
||||||
|
assert( expected === removeDarkModeSpecificImageFromReadme(input));
|
||||||
|
|
||||||
|
console.log("PASS!");
|
||||||
Loading…
Add table
Add a link
Reference in a new issue