Skip to content

Commit

Permalink
Merge pull request #2949 from patrick-rodgers/version-4
Browse files Browse the repository at this point in the history
Updates buildsystem for 4.0 release
  • Loading branch information
patrick-rodgers authored Feb 27, 2024
2 parents 29bdbd8 + 5f03203 commit 5d39286
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 86 deletions.
26 changes: 3 additions & 23 deletions buildsystem-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
WritePackageJSON,
Publish,
PublishNightly,
CreateResolutionPackageFiles,
} from "@pnp/buildsystem";
import {
Logger,
Expand Down Expand Up @@ -48,12 +47,11 @@ function PnPPackage(): (b: BuildTimeline) => BuildTimeline {
CopyAssetFiles(".", ["LICENSE"])(instance);
CopyAssetFiles("./packages", ["readme.md"])(instance);
CopyPackageFiles("built", ["**/*.d.ts", "**/*.js", "**/*.js.map", "**/*.d.ts.map"])(instance);
CreateResolutionPackageFiles()(instance),
WritePackageJSON((p) => {
return Object.assign({}, p, {
type: "module",
main: "./esm/index.js",
typings: "./esm/index",
main: "./index.js",
typings: "./index",
engines: {
node: ">=18.12.0"
},
Expand All @@ -69,19 +67,6 @@ function PnPPackage(): (b: BuildTimeline) => BuildTimeline {
type: "git",
url: "git:github.com/pnp/pnpjs"
},
exports: {
".": {
"import": {
"types": "./esm/index",
"default": "./esm/index.js"
},
"require": {
"types": "./commonjs/index",
"default": "./commonjs/index.js"
},
"default": "./esm/index.js"
}
},
maintainers: [
{
name: "patrick-rodgers",
Expand Down Expand Up @@ -121,14 +106,13 @@ function PnPPublish(flags?: string[]): (b: BuildTimeline) => BuildTimeline {

const commonBehaviors = [
PnPLogging(logLevel),
]
];

export default <BuildSchema[]>[{
name: "build",
distFolder,
targets: [
resolve("./packages/tsconfig.json"),
resolve("./packages/tsconfig-commonjs.json"),
],
behaviors: [PnPBuild(), ...commonBehaviors],
},
Expand All @@ -145,7 +129,6 @@ export default <BuildSchema[]>[{
distFolder,
targets: [
resolve("./packages/tsconfig.json"),
resolve("./packages/tsconfig-commonjs.json"),
],
behaviors: [PnPBuild(), PnPPackage(), ...commonBehaviors],
},
Expand All @@ -154,7 +137,6 @@ export default <BuildSchema[]>[{
distFolder,
targets: [
resolve("./packages/tsconfig.json"),
resolve("./packages/tsconfig-commonjs.json"),
],
behaviors: [PnPBuild(), PnPPackage(), PnPPublish(commonPublishTags), ...commonBehaviors],
},
Expand All @@ -163,7 +145,6 @@ export default <BuildSchema[]>[{
distFolder,
targets: [
resolve("./packages/tsconfig.json"),
resolve("./packages/tsconfig-commonjs.json"),
],
behaviors: [PnPBuild(), PnPPackage(), PnPPublish([...commonPublishTags, "--tag", "beta"]), ...commonBehaviors],
},
Expand All @@ -172,7 +153,6 @@ export default <BuildSchema[]>[{
distFolder,
targets: [
resolve("./packages/tsconfig.json"),
resolve("./packages/tsconfig-commonjs.json"),
],
behaviors: [PnPBuild(), PnPPackage(), PublishNightly([...commonPublishTags], "v4nightly"), ...commonBehaviors],
}];
21 changes: 20 additions & 1 deletion packages/queryable/queryable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export interface Queryable<R = any> extends IInvokable<R> { }
// this interface is required to stop the class from recursively referencing itself through the DefaultBehaviors type
export interface IQueryableInternal<R = any> extends Timeline<any>, IInvokable {
readonly query: URLSearchParams;
// new(...params: any[]);
<T = R>(this: IQueryableInternal, init?: RequestInit): Promise<T>;
using(...behaviors: TimelinePipe[]): this;
toRequestUrl(): string;
Expand Down Expand Up @@ -268,7 +269,7 @@ export function op<T>(q: IQueryableInternal, operation: Operation, init?: Reques
return Reflect.apply(operation, q, [init]);
}

export function queryableFactory<InstanceType extends IQueryableInternal>(
export function queryableFactory<InstanceType>(
constructor: { new(init: QueryableInit, path?: string): InstanceType },
): (init: QueryableInit, path?: string) => InstanceType {

Expand All @@ -286,6 +287,24 @@ export function queryableFactory<InstanceType extends IQueryableInternal>(
};
}

// // extends IQueryableInternal
// export function queryableFactory2<InstanceType extends IQueryableInternal>(constructor: InstanceType):
// (...args: ConstructorParameters<InstanceType>) => InstanceType & IInvokable {

// return (...args: ConstructorParameters<InstanceType>) => {

// // construct the concrete instance
// const instance: InstanceType = new constructor(...args);

// // we emit the construct event from the factory because we need all of the decorators and constructors
// // to have fully finished before we emit, which is now true. We type the instance to any to get around
// // the protected nature of emit
// (<any>instance).emit.construct(...args);

// return instance;
// };
// }

/**
* Allows a decorated object to be invoked as a function, optionally providing an implementation for that action
*
Expand Down
16 changes: 15 additions & 1 deletion packages/sp/spqueryable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { combine, isUrlAbsolute, isArray, objectDefinedNotNull, stringIsNullOrEmpty } from "@pnp/core";
import { IInvokable, Queryable, queryableFactory, op, get, post, patch, del } from "@pnp/queryable";
import { Queryable, queryableFactory, op, get, post, patch, del, IInvokable } from "@pnp/queryable";

export type SPInit = string | ISPQueryable | [ISPQueryable, string];

Expand All @@ -13,6 +13,20 @@ export const spInvokableFactory = <R extends ISPQueryable>(f: any): ISPInvokable
return queryableFactory<R>(f);
};



// export type ISPInvokableFactory2<R extends ISPQueryable> = (...args: any[]) => R & IInvokable;

// export const spInvokableFactory2 = <R extends ISPQueryable<T>, T extends ISPQueryable>(f: T): ISPInvokableFactory2<R> => {





// return queryableFactory2<R>(f);
// };


/**
* SharePointQueryable Base Class
*
Expand Down
2 changes: 1 addition & 1 deletion packages/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "../build/packages/esm"
"outDir": "../build/packages"
},
"include": [],
"references": [
Expand Down
1 change: 0 additions & 1 deletion tools/buildsystem/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export { Publish } from "./src/behaviors/publish.js";
export { ReplaceVersion, IReplaceVersionOptions } from "./src/behaviors/replace-version.js";
export { Webpack } from "./src/behaviors/webpack.js";
export { WritePackageJSON } from "./src/behaviors/write-packagejson.js";
export { CreateResolutionPackageFiles } from "./src/behaviors/create-resolution-package-files.js";

export {
BuildObserver,
Expand Down
2 changes: 1 addition & 1 deletion 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-beta10",
"version": "4.0.0",
"bin": {
"pnpbuild": "bin/buildsystem.js"
},
Expand Down
1 change: 1 addition & 0 deletions tools/buildsystem/src/behaviors/copy-asset-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import buildCopyFile from "../lib/copy-file.js";

/**
* Copies files from a single location and to each project's dist folder
* @param path cwd path for the globby command
* @param pattern glob patterns for files (see https://www.npmjs.com/package/globby)
* @returns
*/
Expand Down
13 changes: 11 additions & 2 deletions tools/buildsystem/src/behaviors/copy-package-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ export function CopyPackageFiles(source: "src" | "built", pattern: string[]): Ti
cwd: fileSourceRoot,
});

// a.push(...temp.map(t => ({
// src: resolve(fileSourceRoot, t),
// dest: resolve(pkg.resolvedPkgDistRoot, source === "built" ? pkg.relativePkgDistModulePath : "", t),
// })));

a.push(...temp.map(t => ({
src: resolve(fileSourceRoot, t),
dest: resolve(pkg.resolvedPkgDistRoot, source === "built" ? pkg.relativePkgDistModulePath : "", t),
dest: resolve(pkg.resolvedPkgDistRoot, t),
})));

return a;
Expand All @@ -43,7 +48,11 @@ export function CopyPackageFiles(source: "src" | "built", pattern: string[]): Ti
}, Promise.resolve<{ src: string, dest: string }[]>([]));

this.log(`CopyPackageFiles found ${files.length} files for pattern ${stringPattern} in target '${target.tsconfigPath}'`);


for (let i = 0; i < files.length; i++) {
this.log(`CopyPackageFiles found ${files[i]}`, 0);
}

await Promise.all(files.map(f => buildCopyFile(f.src, f.dest)));

this.log(`Completing CopyPackageFiles with pattern ${stringPattern} on target '${target.tsconfigPath}'`, 1);
Expand Down
46 changes: 0 additions & 46 deletions tools/buildsystem/src/behaviors/create-resolution-package-files.ts

This file was deleted.

9 changes: 1 addition & 8 deletions tools/buildsystem/src/behaviors/write-packagejson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,10 @@ export function WritePackageJSON(transform?: (p: any) => typeof p): TimelinePipe

let pkgFile = importJSON(resolve(pkg.resolvedPkgSrcRoot, "package.json"));

this.log(`Updating package version at ${pkgFile} to ${version}`, 1);
this.log(`Updating package version at ${pkg.resolvedPkgSrcRoot} to ${version}`, 1);

pkgFile.version = version;

// update our peer dependencies and dependencies placeholder if needed
for (const key in pkgFile.peerDependencies) {
if (pkgFile.peerDependencies[key] === "0.0.0-PLACEHOLDER") {
pkgFile.peerDependencies[key] = version;
}
}

for (const key in pkgFile.dependencies) {
if (pkgFile.dependencies[key] === "0.0.0-PLACEHOLDER") {
pkgFile.dependencies[key] = version;
Expand Down
4 changes: 2 additions & 2 deletions tools/buildsystem/src/build-timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class BuildTimeline extends Timeline<typeof BuildMoments> {
throw Error("No observers registered for this request. (https://pnp.github.io/pnpjs/queryable/queryable#no-observers-registered-for-this-request)");
}

// // schedule the execution after we return the promise below in the next event loop
// schedule the execution after we return the promise below in the next event loop
setTimeout(async () => {

try {
Expand Down Expand Up @@ -72,7 +72,7 @@ export class BuildTimeline extends Timeline<typeof BuildMoments> {

}, 0);

// // this is the promise that the calling code will recieve and await
// this is the promise that the calling code will recieve and await
let promise = new Promise<void>((resolve, reject) => {

// we overwrite any pre-existing internal events as a
Expand Down

0 comments on commit 5d39286

Please sign in to comment.