Skip to content

Commit

Permalink
feat: todo
Browse files Browse the repository at this point in the history
  • Loading branch information
Zamiell committed Oct 31, 2023
1 parent 6f77f30 commit 784116d
Show file tree
Hide file tree
Showing 33 changed files with 432 additions and 318 deletions.
3 changes: 2 additions & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
"scripts": {
"build": "tsx --tsconfig ./scripts/tsconfig.json ./build.mts",
"clear": "docusaurus clear",
"deploy": "docusaurus deploy",
"deploy": "tsx --tsconfig ./scripts/tsconfig.json ./deploy.mts",
"docusaurus": "docusaurus",
"lint": "tsx --tsconfig ./scripts/tsconfig.json ./lint.mts",
"serve": "docusaurus serve",
"start": "docusaurus start",
"swizzle": "docusaurus swizzle",
Expand Down
6 changes: 1 addition & 5 deletions packages/docs/scripts/build.mts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ const GENERATED_DOC_DIRECTORY_NAMES = [
"eslint-config-isaacscript",
] as const;

await buildScript(async ({ packageRoot, outDir }) => {
if (outDir === undefined) {
outDir = "dist"; // eslint-disable-line no-param-reassign
}

await buildScript(async ({ packageRoot }) => {
const generatedDocPaths = GENERATED_DOC_DIRECTORY_NAMES.map((directoryName) =>
path.join(packageRoot, "docs", directoryName),
);
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-plugin-isaacscript/scripts/build.mts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ await buildScript(async ({ outDir, packageRoot }) => {
outDir,
'Failed to get the "outDir" from the "tsconfig.json" file.',
);
rm(outDir);

await buildTypeScript(packageRoot);
copyToMonorepoNodeModules(packageRoot, outDir);
Expand Down
11 changes: 2 additions & 9 deletions packages/isaac-lua-polyfill/scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { buildScript, buildTypeScript, rm } from "isaacscript-common-node";
import { assertDefined } from "isaacscript-common-ts";

await buildScript(async ({ outDir, packageRoot }) => {
assertDefined(
outDir,
'Failed to get the "outDir" from the "tsconfig.json" file.',
);
rm(outDir);
import { buildScript, buildTypeScript } from "isaacscript-common-node";

await buildScript(async ({ packageRoot }) => {
await buildTypeScript(packageRoot);
});
4 changes: 2 additions & 2 deletions packages/isaac-typescript-definitions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
"README.md"
],
"scripts": {
"build": "tsx scripts/build.ts",
"build": "tsx --tsconfig ./scripts/tsconfig.json ./scripts/build.ts",
"docs": "typedoc",
"lint": "tsx scripts/lint.ts"
"lint": "tsx --tsconfig ./scripts/tsconfig.json ./scripts/lint.ts"
},
"dependencies": {
"lua-types": "^2.13.1"
Expand Down
11 changes: 2 additions & 9 deletions packages/isaac-typescript-definitions/scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { $, buildScript, buildTypeScript, rm } from "isaacscript-common-node";
import { assertDefined } from "isaacscript-common-ts";

await buildScript(async ({ outDir, packageRoot }) => {
assertDefined(
outDir,
'Failed to get the "outDir" from the "tsconfig.json" file.',
);
rm(outDir);
import { $, buildScript, buildTypeScript } from "isaacscript-common-node";

await buildScript(async ({ packageRoot }) => {
const promises: Array<Promise<unknown>> = [];

promises.push(
Expand Down
6 changes: 2 additions & 4 deletions packages/isaac-typescript-definitions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"extends": [
"../isaacscript-tsconfig/tsconfig.base.json",
"../../tsconfig.monorepo.json",
],
// We cannot extend from the monorepo TSConfig since TSTL will complain about "paths".
"extends": "../isaacscript-tsconfig/tsconfig.base.json",

// https://www.typescriptlang.org/docs/handbook/compiler-options.html
"compilerOptions": {
Expand Down
17 changes: 2 additions & 15 deletions packages/isaacscript-cli/scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
import {
$,
$s,
buildScript,
buildTypeScript,
rm,
} from "isaacscript-common-node";
import { assertDefined } from "isaacscript-common-ts";
import { $, $s, buildScript, buildTypeScript } from "isaacscript-common-node";

const TSCONFIG_SCHEMA_PATH = "schemas/tsconfig-isaacscript-section-schema.json";
const ISAACSCRIPT_SCHEMA_PATH = "schemas/isaacscript-schema.json";

await buildScript(async ({ outDir, packageRoot }) => {
assertDefined(
outDir,
'Failed to get the "outDir" from the "tsconfig.json" file.',
);
rm(outDir);

await buildScript(async ({ packageRoot }) => {
const promises: Array<Promise<unknown>> = [];

promises.push(
Expand Down
4 changes: 2 additions & 2 deletions packages/isaacscript-cli/src/commands/publish/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
PACKAGE_JSON,
fatalError,
isFile,
isGitClean,
isGitRepository,
isGitRepositoryClean,
isLoggedInToNPM,
} from "isaacscript-common-node";
import { PROJECT_NAME } from "../../constants.js";
Expand All @@ -21,7 +21,7 @@ export function validate(
);
}

if (!isGitClean()) {
if (!isGitRepositoryClean()) {
fatalError(
"Failed to publish since the Git repository was dirty. Before publishing, you must push any current changes to git. (Version commits should not contain any code changes.)",
);
Expand Down
11 changes: 11 additions & 0 deletions packages/isaacscript-common-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist",
"src",
"LICENSE",
"package.json",
"README.md"
],
"scripts": {
"build": "tsx ./scripts/build.ts",
"lint": "tsx ./scripts/lint.ts"
},
"dependencies": {
"@arktype/fs": "^0.0.1",
"chalk": "^5.3.0",
Expand Down
38 changes: 0 additions & 38 deletions packages/isaacscript-common-node/scripts/build.sh

This file was deleted.

5 changes: 5 additions & 0 deletions packages/isaacscript-common-node/scripts/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { buildScript, buildTypeScript } from "isaacscript-common-node";

await buildScript(async ({ packageRoot }) => {
await buildTypeScript(packageRoot);
});
32 changes: 0 additions & 32 deletions packages/isaacscript-common-node/scripts/lint.sh

This file was deleted.

9 changes: 9 additions & 0 deletions packages/isaacscript-common-node/scripts/lint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { $, lintScript } from "isaacscript-common-node";

await lintScript(async () => {
const promises: Array<Promise<unknown>> = [];

promises.push($`tsc --noEmit`, $`eslint --max-warnings 0 .`);

await Promise.all(promises);
});
24 changes: 22 additions & 2 deletions packages/isaacscript-common-node/src/functions/scriptHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import path from "node:path";
import { dirOfCaller, findPackageRoot } from "./arkType.js";
import { rm } from "./file.js";
import { getElapsedSeconds } from "./time.js";
import { getTSConfigJSONOutDir } from "./tsconfigJSON.js";
import { getArgs } from "./utils.js";
Expand All @@ -15,9 +16,28 @@ interface ScriptCallbackData {
outDir?: string;
}

/** See the documentation for the `script` helper function. */
/**
* Removes the "outdir" directory specified in the "tsconfig.json" file (if it exists), then runs
* the provided logic.
*
* For more information, see the documentation for the `script` helper function.
*/
export async function buildScript(func: ScriptCallback): Promise<void> {
await script(func, "built", 2);
await script(
async (data) => {
const { outDir } = data;
if (outDir !== undefined) {
rm(outDir);
}

// We do not want to execute the `buildTypeScript` helper function automatically because the
// end-user might want to do that in parallel with other tasks.

await func(data);
},
"built",
2,
);
}

/** See the documentation for the `script` helper function. */
Expand Down
14 changes: 13 additions & 1 deletion packages/isaacscript-common-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,17 @@
"author": "Zamiell",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts"
"types": "./dist/index.d.ts",
"files": [
"dist",
"src",
"LICENSE",
"package.json",
"README.md"
],
"scripts": {
"build": "tsx ./scripts/build.ts",
"lint": "tsx ./scripts/lint.ts",
"test": "jest"
}
}
38 changes: 0 additions & 38 deletions packages/isaacscript-common-ts/scripts/build.sh

This file was deleted.

5 changes: 5 additions & 0 deletions packages/isaacscript-common-ts/scripts/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { buildScript, buildTypeScript } from "isaacscript-common-node";

await buildScript(async ({ packageRoot }) => {
await buildTypeScript(packageRoot);
});
32 changes: 0 additions & 32 deletions packages/isaacscript-common-ts/scripts/lint.sh

This file was deleted.

9 changes: 9 additions & 0 deletions packages/isaacscript-common-ts/scripts/lint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { $, lintScript } from "isaacscript-common-node";

await lintScript(async () => {
const promises: Array<Promise<unknown>> = [];

promises.push($`tsc --noEmit`, $`eslint --max-warnings 0 .`);

await Promise.all(promises);
});
11 changes: 0 additions & 11 deletions packages/isaacscript-common-ts/scripts/test.sh

This file was deleted.

Loading

0 comments on commit 784116d

Please sign in to comment.