Skip to content

Commit

Permalink
feat: implement verify integrity check (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hotell committed May 22, 2024
1 parent f2d53e6 commit 348d8fb
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- name: Install Playwright Browsers
run: npx playwright install --with-deps

- run: yarn nx affected --target=verify-integrity --parallel --max-parallel=3
- run: yarn nx affected --target=type-check --parallel --max-parallel=3
- run: yarn nx affected --target=build --parallel --max-parallel=3
- run: yarn nx affected --target=build-storybook --parallel --max-parallel=3
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fluentui-contrib",
"private": true,
"version": "0.1.0",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"build": "nx affected --target=build",
Expand Down
3 changes: 3 additions & 0 deletions project.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"config": ".verdaccio/config.yml",
"storage": "tmp/local-registry/storage"
}
},
"verify-integrity": {
"command": "node ./tools/scripts/verify-repo-integrity.mjs"
}
}
}
42 changes: 42 additions & 0 deletions tools/scripts/verify-repo-integrity.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// @ts-check

import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
import { readFileSync } from 'node:fs';

import chalk from 'chalk';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

main();

function main() {
/**
* @type {string[]}
*/
const log = [];

log.push(verifyPackageJson());

log.forEach((message) => {
console.log(`- ✅ ${chalk.bold.green(message)}`);
});
}

function verifyPackageJson() {
/** @type {import('nx/src/utils/package-json').PackageJson} */
const json = JSON.parse(
readFileSync(join(__dirname, '../../package.json'), 'utf-8')
);

if (json.private !== true) {
throw new Error('The package.json must have a private field set to true');
}

if (json.version !== '0.0.0') {
throw new Error('The package.json must have a version field set to 0.0.0');
}

return 'The package.json is valid.';
}

0 comments on commit 348d8fb

Please sign in to comment.