Files
self/scripts/check-duplicate-headers.cjs
Justin Hernandez 20fa5c5adc [SELF-700] feat: add mock document generator demo (#995)
* feat: add mock document generator demo

* feat: add mock document generator

* fixes

* chore: refresh workflow cache

* update lock

* build

* updates

* more fixes

* code rabbit feedback

* compiles

* save wip

* updates

* merge with dev and fixes

* fix: align hoisting and demo Jest resolver (#1003)

* chore(app): map common src paths and declare svg flag module

* ci fix

* update lock

* save wip

* chore: address yarn lock issues (#1004)

* address yarn lock issues

* fix postinstall

* fix ci

* use metro js proxy

* android build working for /app

* save wip

* fix merge

* pipeline fixes

* format

* fix pipelines

* bump limit and split

* fix pipeline issues

* chore: decouple demo app build (#1013)

* chore: decouple demo app build

* chore: move demo app to workspace

* chore: unpublish demo workspace

* fix mobile sdk tests

* updates

* remove polyfills

* update merge

* update resolutions

* update resolutions

* fix merge

* fix paths

* save wip

* save wip fixes rd2

* working android

* update lock

* save wip ios building

* fix merge

* readd public key

* fixes

* ci fixes

* fixes

* fix web building

* fix ci

* fix tests

* update lock

* fix ci rd2

* formatting and fix ci

* fix

* finalize ci fixes

* fix tests and metro config paths for building

* save wip

* install missing package for pipeline

* fix wip app building

* wip react config

* save working emulator compile

* first round of pr fixes and feedback

* clean up demo app artifacts from sdk

* Add Gradle wrapper files for mobile-sdk-demo Android build

- Added gradlew, gradlew.bat, and gradle/wrapper/ directory
- Updated .gitignore to allow committing Gradle wrapper files
- Fixes Android build error: spawn ./gradlew ENOENT

* codex feedback and fixes

* fix tests

* file renames

* revert back to dev

* add types

* coderabbit fixes

* fix tests

* fix tests

* fix test

* fixes

* fix wip coderabbit issues

* coderabbit suggestions rd 2

* fix ci pipelines and addresss warnings

* cr fixes

* convert kebab to camelCase

* save wip fixes

* update reinstall and lock files

* fixes

* remove file

* fix lint

* fix polyfill fallback issues

* ensure that mock document is not on ofac list

* prettier
2025-09-27 13:59:47 -07:00

78 lines
2.2 KiB
JavaScript

#!/usr/bin/env node
// SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc.
// SPDX-License-Identifier: BUSL-1.1
// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.
const fs = require('fs');
const path = require('path');
const { glob } = require('glob');
const LICENSE_HEADER_PATTERN = /^\/\/\s*SPDX-FileCopyrightText:/;
const EXTENSIONS = ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'];
function checkFile(filePath) {
const content = fs.readFileSync(filePath, 'utf8');
const lines = content.split('\n');
const headerLines = lines
.map((line, index) => ({ line, index: index + 1 }))
.filter(({ line }) => LICENSE_HEADER_PATTERN.test(line));
if (headerLines.length > 1) {
console.error(`\n❌ Multiple license headers found in ${filePath}:`);
headerLines.forEach(({ index }) => {
console.error(` Line ${index}`);
});
return false;
}
return true;
}
function main() {
const args = process.argv.slice(2);
const targetDirs = args.filter(arg => !arg.startsWith('--'));
const directories = targetDirs.length > 0
? targetDirs.map(dir => path.resolve(dir))
: [process.cwd()];
let hasErrors = false;
// Get all relevant files from all directories
const patterns = EXTENSIONS.map(ext => path.join('src', ext));
patterns.push(...EXTENSIONS.map(ext => path.join('tests', ext)));
patterns.push(...EXTENSIONS.map(ext => path.join('scripts', ext)));
patterns.push('*.ts', '*.tsx', '*.js', '*.jsx');
for (const targetDir of directories) {
for (const pattern of patterns) {
const files = glob
.sync(pattern, {
cwd: targetDir,
ignore: ['node_modules/**', 'dist/**', 'build/**', '**/*.d.ts'],
})
.map(file => path.join(targetDir, file));
for (const file of files) {
if (!checkFile(file)) {
hasErrors = true;
}
}
}
}
if (hasErrors) {
console.error(
'\n💡 Fix: Remove duplicate license headers. Only keep the one at the top of each file.\n',
);
process.exit(1);
} else {
console.log('✅ No duplicate license headers found');
}
}
if (require.main === module) {
main();
}
module.exports = { checkFile };