Skip to content

Commit

Permalink
Merge pull request #2868 from patrick-rodgers/version-4
Browse files Browse the repository at this point in the history
more build system :)
  • Loading branch information
patrick-rodgers authored Dec 20, 2023
2 parents a8d7464 + dee2f52 commit b6c1034
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 231 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,3 @@ settings.js

# don't save the locally produced .js of the buildsystem config
buildsystem-config.js
buildsystem-config2.js
4 changes: 2 additions & 2 deletions tools/buildsystem/bin/buildsystem.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

import Liftoff from "liftoff";
import * as Liftoff from "liftoff";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { dirname, join, resolve } from "path";
Expand All @@ -15,7 +15,7 @@ const context: Partial<IBuildContext> = {
resolvedProjectRoot: join(cwd(), "package.json"),
};

const BuildSystem = new Liftoff({
const BuildSystem = new (<any>Liftoff).default({
configName: "buildsystem-config",
name: "buildsystem",
});
Expand Down
233 changes: 22 additions & 211 deletions tools/buildsystem/package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions tools/buildsystem/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pnp/buildsystem",
"version": "4.0.0-beta3",
"version": "4.0.0-beta4",
"bin": {
"pnpbuild": "bin/buildsystem.js"
},
Expand All @@ -12,7 +12,6 @@
"@pnp/core": "^3.21.0",
"globby": "^14.0.0",
"liftoff": "^4.0.0",
"replace-in-file": "^7.0.2",
"webpack": "^5.89.0",
"yargs": "^17.7.2"
},
Expand Down
2 changes: 1 addition & 1 deletion tools/buildsystem/src/behaviors/copy-asset-files.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TimelinePipe } from "@pnp/core";
import { BuildTimeline } from "../build-timeline.js";
import globby from "globby";
import { globby } from "globby";
import { resolve } from "path";
import buildCopyFile from "../lib/copy-file.js";

Expand Down
2 changes: 1 addition & 1 deletion tools/buildsystem/src/behaviors/copy-package-files.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TimelinePipe } from "@pnp/core";
import { BuildTimeline } from "../build-timeline.js";
import globby from "globby";
import { globby } from "globby";
import { resolve } from "path";
import buildCopyFile from "../lib/copy-file.js";

Expand Down
22 changes: 13 additions & 9 deletions tools/buildsystem/src/behaviors/replace-version.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { TimelinePipe } from "@pnp/core";
import { BuildTimeline } from "../build-timeline.js";
import { readFile } from "fs/promises";
import buildWriteFile from "src/lib/write-file.js";
import { resolve } from "path";
import { BuildTimeline } from "src/build-timeline";
import replace from "replace-in-file";

export function ReplaceVersion(paths: string[], versionMask = /\$\$Version\$\$/ig): TimelinePipe {

Expand All @@ -13,13 +14,16 @@ export function ReplaceVersion(paths: string[], versionMask = /\$\$Version\$\$/i

this.log(`Replacing package version for target "${target.tsconfigPath}"`, 1);

const options = {
files: paths.map(p => resolve(target.resolvedOutDir, p)),
from: versionMask,
to: version,
};

return (<any>replace)(options);
paths.forEach(async (path) => {

const file = await readFile(resolve(path));

const txt = file.toString();

txt.replace(versionMask, version);

await buildWriteFile(path, txt);
});
});

return instance;
Expand Down
3 changes: 1 addition & 2 deletions tools/buildsystem/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
"strictNullChecks": false,
"preserveConstEnums": true,
"importHelpers": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true
"resolveJsonModule": true
},
"include": [
"./index.ts",
Expand Down
4 changes: 2 additions & 2 deletions tools/local-module-resolver/esm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { existsSync } from "fs";
import findup from "findup-sync";

// give ourselves a single reference to the projectRoot
const projectRoot = resolve(dirname(findup("package.json")));
const projectRoot = resolve(dirname(findup("package.json")!));

function log(_message: string) {
// console.log(`PnP Node Local Module Loader: ${message}`);
Expand All @@ -23,7 +23,7 @@ export function createResolve(innerPath: string): ResolverFunc {
const modulePath = specifier.substring(4);

if (cache.has(modulePath)) {
return cache.get(modulePath);
return cache.get(modulePath)!;
}

let candidate = join(projectRoot, innerPath, modulePath);
Expand Down

0 comments on commit b6c1034

Please sign in to comment.