Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
include:
- package: streaming/mime-bytes
- package: uploads/mime-bytes
env: {}
- package: pgpm/core
env: {}
Expand All @@ -43,9 +43,9 @@ jobs:
env: {}
- package: packages/url-domains
env: {}
- package: streaming/uuid-hash
- package: uploads/uuid-hash
env: {}
- package: streaming/uuid-stream
- package: uploads/uuid-stream
env: {}
- package: postgres/introspectron
env: {}
Expand All @@ -59,12 +59,12 @@ jobs:
env: {}
- package: postgres/pg-codegen
env: {}
- package: streaming/content-type-stream
- package: uploads/content-type-stream
env: {}
- package: streaming/s3-streamer
- package: uploads/s3-streamer
env:
BUCKET_NAME: test-bucket
- package: streaming/upload-names
- package: uploads/upload-names
env: {}
- package: graphile/graphile-test
env: {}
Expand Down
2 changes: 1 addition & 1 deletion graphql/explorer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
<img height="20" src="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml/badge.svg" />
</a>
<a href="https://github.com/constructive-io/constructive/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
<a href="https://www.npmjs.com/package/@constructive-io/graphql-explorer"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=packages%2Fexplorer%2Fpackage.json"/></a>
<a href="https://www.npmjs.com/package/@constructive-io/graphql-explorer"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=graphql%2Fexplorer%2Fpackage.json"/></a>
</p>
2 changes: 1 addition & 1 deletion graphql/gql-ast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Super bare-bones GraphQL AST utils
<img height="20" src="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml/badge.svg" />
</a>
<a href="https://github.com/constructive-io/constructive/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
<a href="https://www.npmjs.com/package/gql-ast"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=packages%2Fgql-ast%2Fpackage.json"/></a>
<a href="https://www.npmjs.com/package/gql-ast"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=graphql%2Fgql-ast%2Fpackage.json"/></a>
</p>

```sh
Expand Down
2 changes: 1 addition & 1 deletion graphql/query/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<img height="20" src="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml/badge.svg" />
</a>
<a href="https://github.com/constructive-io/constructive/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
<a href="https://www.npmjs.com/package/@constructive-io/graphql-query"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=packages%query%2Fpackage.json"/></a>
<a href="https://www.npmjs.com/package/@constructive-io/graphql-query"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=graphql%2Fquery%2Fpackage.json"/></a>
</p>

> Fluent GraphQL query and mutation builder for PostGraphile-based schemas.
Expand Down
2 changes: 1 addition & 1 deletion graphql/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
<img height="20" src="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml/badge.svg" />
</a>
<a href="https://github.com/constructive-io/constructive/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
<a href="https://www.npmjs.com/package/@constructive-io/graphql-react"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=packages%2Freact%2Fpackage.json"/></a>
<a href="https://www.npmjs.com/package/@constructive-io/graphql-react"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=graphql%2Freact%2Fpackage.json"/></a>
</p>
8 changes: 4 additions & 4 deletions pgpm/cli/__tests__/__snapshots__/init.install.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ exports[`cmds:install - with initialized workspace and module installs a module
},
"description": "my-module",
"devDependencies": {
"makage": "0.1.8",
"pgsql-test": "^2.16.2",
"makage": "<VERSION>",
"pgsql-test": "<VERSION>",
},
"homepage": "https://github.com/tester/my-module",
"keywords": [],
Expand Down Expand Up @@ -150,8 +150,8 @@ exports[`cmds:install - with initialized workspace and module installs two modul
},
"description": "my-module",
"devDependencies": {
"makage": "0.1.8",
"pgsql-test": "^2.16.2",
"makage": "<VERSION>",
"pgsql-test": "<VERSION>",
},
"homepage": "https://github.com/tester/my-module",
"keywords": [],
Expand Down
14 changes: 11 additions & 3 deletions pgpm/cli/__tests__/init.install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as fs from 'fs';
import * as glob from 'glob';
import * as path from 'path';

import { TestFixture } from '../test-utils';
import { TestFixture, normalizePackageJsonForSnapshot } from '../test-utils';

describe('cmds:install - with initialized workspace and module', () => {
let fixture: TestFixture;
Expand Down Expand Up @@ -55,7 +55,11 @@ describe('cmds:install - with initialized workspace and module', () => {
const pkgJson = JSON.parse(
fs.readFileSync(path.join(moduleDir, 'package.json'), 'utf-8')
);
expect(pkgJson).toMatchSnapshot();
// Normalize package.json for snapshot, preserving versions for explicitly installed packages
const normalizedPkgJson = normalizePackageJsonForSnapshot(pkgJson, {
preserveVersionsFor: ['@pgpm-testing/base32']
});
expect(normalizedPkgJson).toMatchSnapshot();

const installedFiles = glob.sync('**/*', {
cwd: path.join(workspaceDir, 'extensions'),
Expand Down Expand Up @@ -99,7 +103,11 @@ describe('cmds:install - with initialized workspace and module', () => {
const pkgJson = JSON.parse(
fs.readFileSync(path.join(moduleDir, 'package.json'), 'utf-8')
);
expect(pkgJson).toMatchSnapshot();
// Normalize package.json for snapshot, preserving versions for explicitly installed packages
const normalizedPkgJson = normalizePackageJsonForSnapshot(pkgJson, {
preserveVersionsFor: ['@pgpm-testing/base32', '@pgpm-testing/utils']
});
expect(normalizedPkgJson).toMatchSnapshot();

const extPath = path.join(workspaceDir, 'extensions');
const installedFiles = glob.sync('**/*', {
Expand Down
40 changes: 40 additions & 0 deletions pgpm/cli/test-utils/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,46 @@ import readline from 'readline';
import { Readable, Transform, Writable } from 'stream';
import { cleanAnsi } from 'clean-ansi';

/**
* Normalizes a package.json object for snapshot testing by replacing
* dependency versions with a placeholder. This prevents snapshot failures
* when boilerplate/tooling dependency versions change.
*
* @param pkgJson - The parsed package.json object
* @param options - Configuration options
* @param options.preserveVersionsFor - Array of package names whose versions should be preserved (not normalized)
* @returns A new object with normalized dependency versions
*/
export function normalizePackageJsonForSnapshot(
pkgJson: Record<string, unknown>,
options: { preserveVersionsFor?: string[] } = {}
): Record<string, unknown> {
const { preserveVersionsFor = [] } = options;
const result = { ...pkgJson };

const depFields = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'] as const;

for (const field of depFields) {
const deps = result[field];
if (deps && typeof deps === 'object' && !Array.isArray(deps)) {
const normalizedDeps: Record<string, string> = {};
const sortedKeys = Object.keys(deps as Record<string, string>).sort();

for (const key of sortedKeys) {
if (preserveVersionsFor.includes(key)) {
normalizedDeps[key] = (deps as Record<string, string>)[key];
} else {
normalizedDeps[key] = '<VERSION>';
}
}

result[field] = normalizedDeps;
}
}

return result;
}

export const KEY_SEQUENCES = {
ENTER: '\u000d',
UP_ARROW: '\u001b[A',
Expand Down
1 change: 1 addition & 0 deletions pgpm/cli/test-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './CLIDeployTestFixture';
export * from './fixtures';
export * from './init-argv';
export * from './TestDatabase';
export { normalizePackageJsonForSnapshot } from './cli';
2 changes: 1 addition & 1 deletion pgpm/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<img height="20" src="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml/badge.svg" />
</a>
<a href="https://github.com/constructive-io/constructive/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
<a href="https://www.npmjs.com/package/@pgpmjs/core"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=packages%2Fcore%2Fpackage.json"/></a>
<a href="https://www.npmjs.com/package/@pgpmjs/core"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=pgpm%2Fcore%2Fpackage.json"/></a>
</p>

## Overview
Expand Down
2 changes: 1 addition & 1 deletion pgpm/types/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
<img height="20" src="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml/badge.svg" />
</a>
<a href="https://github.com/constructive-io/constructive/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
<a href="https://www.npmjs.com/package/@pgpmjs/types"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=packages%2Ftypes%2Fpackage.json"/></a>
<a href="https://www.npmjs.com/package/@pgpmjs/types"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=pgpm%2Ftypes%2Fpackage.json"/></a>
</p>
Loading