Skip to content

Commit f9a7d6b

Browse files
committed
Merge branch 'develop'
2 parents 4bbec30 + d34ab7f commit f9a7d6b

21 files changed

Lines changed: 2283 additions & 60 deletions

.delivery/.temp/.tsbuildinfo

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2022", // Compile to ES2020 JavaScript (modern browsers)
4+
"module": "NodeNext", // Use ES2020 modules (import/export)
5+
"moduleResolution": "NodeNext", // Resolve modules in a way that supports ESM and modern resolution strategies
6+
"strict": true, // Enable strict type-checking options
7+
"esModuleInterop": true, // Enable interoperability between CommonJS and ES modules
8+
"skipLibCheck": true, // Skip type checking of declaration files for faster builds
9+
"forceConsistentCasingInFileNames": true, // Ensure consistent casing in file names
10+
"baseUrl": "../../",
11+
"rootDir": "../../src",
12+
"paths": {
13+
"@src/*": ["./src/*"]
14+
},
15+
"resolveJsonModule": true,
16+
"outDir": "../.builds/dist/code",
17+
"declarationDir": "../.builds/dist/types",
18+
"declaration": true, // Generate `.d.ts` declaration files
19+
"declarationMap": true, // Generate map files for declarations
20+
"sourceMap": true, // Generate source maps
21+
"lib": ["es2022"], // Include ES2020 features (e.g., BigInt, Nullish Coalescing)
22+
"skipDefaultLibCheck": true // Skip checking default lib files (faster builds)
23+
},
24+
"include": [
25+
"../../src/**/*.ts" // Include all TypeScript files in the "src" directory
26+
],
27+
"exclude": [
28+
"node_modules" // Exclude node_modules directory
29+
]
30+
}

.delivery/scripts/build.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
3+
import { execSync } from 'child_process';
4+
5+
const commands: string[] = [
6+
'npm run test:foundation',
7+
'npm run lint',
8+
"npm run package:lint:readme",
9+
'rimraf ./.delivery/.builds/dist',
10+
'tsc -p ./.delivery/configuration/tsconfig.json',
11+
'npm run package:de-alias',
12+
'npm run package:bundle:copy',
13+
'npm run package:pack',
14+
'npm run package:test:usage',
15+
];
16+
17+
try {
18+
commands.forEach((cmd) => {
19+
console.log(`Running: ${cmd}`);
20+
execSync(cmd, { stdio: 'inherit' });
21+
});
22+
} catch (_error) {
23+
const error = _error as Error;
24+
25+
console.error(`Error running command: ${error.message}`);
26+
27+
process.exit(1);
28+
}

.github/workflows/null-object.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: null-object package test with coverage
2+
3+
on:
4+
push:
5+
branches:
6+
# - never # Skip the workflow for debugging purposes;
7+
# - implement/package-ci # NB: For debugging only
8+
- develop
9+
- master
10+
paths:
11+
- ".github/workflows/null-object.yml"
12+
- "readme.md"
13+
- "package.json"
14+
- "src/**"
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
permissions: write-all
20+
env:
21+
GITHUB_AUTH_TOKEN: ${{ secrets.GH_AUTH_TOKEN }} # NB: Cannot use 'GITHUB_' prefix
22+
23+
name: Test, publish coverage
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Set up Node 20
29+
uses: actions/setup-node@v3
30+
with:
31+
node-version: 20
32+
33+
# Install dependencies and build the package to test in .usage folder
34+
- name: Install dependencies and build the package
35+
run: |
36+
npm install
37+
cd .usage && npm install
38+
cd ../
39+
npm run package:build
40+
41+
- name: Testing the latest build at usage .usage subfolder
42+
working-directory: ./.usage
43+
run: |
44+
npm install
45+
npm run test:usage
46+
47+
- name: Run tests and collect coverage
48+
# NB: See https://app.codecov.io/gh/WhereJuly/60-1-oas-markdown-merger/tests/new
49+
# NB: See https://app.codecov.io/gh/WhereJuly/60-1-oas-markdown-merger/new
50+
run: npm run test:foundation -- --coverage
51+
52+
# I need this step only run for the paths mentioned above AND for only `master` branch;`
53+
# create and push the `<package-name>@v<package-version>` tag to the monorepo
54+
# Take the package name and version from package.json
55+
- name: Create and push tag on master branch only
56+
# NB: For debugging
57+
# if: github.ref_name == 'implement/package-ci'
58+
if: github.ref_name == 'master'
59+
run: |
60+
# Extract package name and version from package.json
61+
PACKAGE_NAME=$(jq -r .name package.json)
62+
PACKAGE_VERSION=$(jq -r .version package.json)
63+
64+
# Create the tag
65+
# TAG="${PACKAGE_NAME}@${PACKAGE_VERSION}" # Only for monorepos
66+
TAG="${PACKAGE_VERSION}"
67+
git tag $TAG
68+
69+
# Push the tag to the repository
70+
git push origin $TAG
71+
72+
# - name: Push the package subtree to a dedicated repo
73+
# NB: See the code for this step in https://lean-web-enterprise.atlassian.net/browse/DCPLDOAS-68
74+
75+
- name: Upload coverage reports to Codecov
76+
# NB: For debugging
77+
# if: github.ref_name == 'implement/package-ci'
78+
if: github.ref_name == 'master'
79+
uses: codecov/codecov-action@v5
80+
with:
81+
token: ${{ secrets.CODECOV_TOKEN }}
82+
slug: WhereJuly/68-null-object

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# build output
22
dist/
33
.builds
4+
.delivery/.temp
5+
.coverage
46

57
# dependencies
68
node_modules/

.usage/examples.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
console.log('dummy');

.usage/package-lock.json

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.usage/package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "usage",
3+
"version": "0.0.0",
4+
"description": "The internal usage package is a part of parent package to independently test the parent package usage as an external dependency.",
5+
"main": "index.ts",
6+
"type": "module",
7+
"private": true,
8+
"scripts": {
9+
"test:usage": "npm install && npm run types:check && vitest run --config tests/vitest.config.ts",
10+
"types:check": "npx tsc --noEmit --project .",
11+
"pre-push": "npm run test:usage"
12+
},
13+
"license": "UNLICENSED",
14+
"dependencies": {
15+
"@wherejuly/null-object": "file:../.delivery/.builds/dist"
16+
}
17+
}

.usage/tests/Usage.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
3+
import { describe, expect, it } from 'vitest';
4+
5+
import { noop, nullObject } from '@wherejuly/null-object';
6+
7+
describe('Null-Object & noop Function Usage Test', () => {
8+
9+
it('Should access properties or methods on Null-Object', () => {
10+
const actual = nullObject();
11+
12+
expect(actual.dummy).toBeInstanceOf(Function);
13+
expect(actual.dummy.another).toBeInstanceOf(Function);
14+
expect(actual.dummy().another.more()).toBeInstanceOf(Function);
15+
expect(actual.method()).toBeInstanceOf(Function);
16+
expect(actual.method(123).another('abc')).toBeInstanceOf(Function);
17+
});
18+
19+
it('Should be able to silently accept assignments to properties', () => {
20+
const actual = nullObject<{ dummy: any; }>();
21+
22+
actual.dummy = 123;
23+
actual.dummy.another = 'abc';
24+
25+
expect(actual.dummy).toBeInstanceOf(Function);
26+
expect(actual.dummy.another).toBeInstanceOf(Function);
27+
});
28+
29+
it('Should output a custom null-object identity name', () => {
30+
const fixture = 'Fixture name';
31+
const actual = nullObject(fixture);
32+
33+
expect(actual.toString()).toEqual(`[NullObject: ${fixture}]`); // NOSONAR
34+
});
35+
36+
it('noop: Should accept any arguments without throwing', () => {
37+
expect(() => noop(1, 'a', true, null)).not.toThrow();
38+
});
39+
40+
});

.usage/tests/vitest.config.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict';
2+
3+
import { fileURLToPath, pathToFileURL } from 'node:url';
4+
import { cwd } from 'node:process';
5+
import { configDefaults, defineConfig } from 'vitest/config';
6+
7+
const root = pathToFileURL(cwd()).toString();
8+
9+
export default defineConfig({
10+
plugins: [],
11+
resolve: {
12+
alias: {
13+
'@tests': fileURLToPath(new URL(`${root}/tests`, import.meta.url)),
14+
}
15+
},
16+
test: {
17+
/**
18+
* WARNING: To prevent tests hanging.
19+
* @see https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker
20+
*/
21+
pool: 'forks',
22+
fileParallelism: false,
23+
cache: false,
24+
reporters: ['verbose'],
25+
globals: true,
26+
exclude: configDefaults.exclude,
27+
root: fileURLToPath(new URL('./', import.meta.url)),
28+
chaiConfig: {
29+
truncateThreshold: 200
30+
}
31+
}
32+
});

0 commit comments

Comments
 (0)