Skip to content
Open
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
2 changes: 1 addition & 1 deletion packages/react-devtools-fusebox/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-devtools-fusebox",
"version": "0.0.0",
"private": "true",
"private": true,
"license": "MIT",
"files": ["dist"],
"scripts": {
Expand Down
57 changes: 57 additions & 0 deletions scripts/validate-all-package-private-fields.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env node
'use strict';

/**
* Scans all packages/ directories and validates that `private` field
* (if present) is a boolean, per npm specification.
*
* Usage: node scripts/validate-all-package-private-fields.js
*/

const fs = require('fs');
const path = require('path');

function validatePrivateField(packageJsonPath) {
const content = fs.readFileSync(packageJsonPath, 'utf8');
const pkg = JSON.parse(content);

if ('private' in pkg) {
if (typeof pkg.private !== 'boolean') {
return {
path: packageJsonPath,
error: `private must be boolean, got ${typeof pkg.private} ("${pkg.private}")`
};
}
}
return null;
}

const packagesDir = 'packages';
const entries = fs.readdirSync(packagesDir);
const packages = entries.filter(e => {
try {
const stat = fs.statSync(path.join(packagesDir, e));
return stat.isDirectory() && fs.existsSync(path.join(packagesDir, e, 'package.json'));
} catch {
return false;
}
});

let hasError = false;
for (const pkgName of packages) {
const pkgPath = path.join(packagesDir, pkgName, 'package.json');
const error = validatePrivateField(pkgPath);
if (error) {
console.error(`ERROR: ${pkgName}: ${error.error}`);
hasError = true;
} else {
console.log(`✓ ${pkgName}`);
}
}

if (hasError) {
console.error('\nValidation failed: some packages have invalid private fields');
process.exit(1);
} else {
console.log(`\nAll ${packages.length} packages passed validation`);
}
43 changes: 43 additions & 0 deletions scripts/validate-package-private-field.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env node
'use strict';

/**
* Validates that the `private` field in package.json is a boolean.
* Per npm specification, `private` must be a boolean value.
*
* Usage: node scripts/validate-package-private-field.js <package-json-path>
*/

const fs = require('fs');
const path = require('path');

function validatePrivateField(packageJsonPath) {
const content = fs.readFileSync(packageJsonPath, 'utf8');
const pkg = JSON.parse(content);

if ('private' in pkg) {
if (typeof pkg.private !== 'boolean') {
console.error(
`ERROR: 'private' field in ${path.relative(process.cwd(), packageJsonPath)} ` +
`must be a boolean, got ${typeof pkg.private} ("${pkg.private}")`
);
process.exit(1);
}
console.log(`✓ ${path.relative(process.cwd(), packageJsonPath)}: private=${pkg.private} (boolean)`);
} else {
console.log(`✓ ${path.relative(process.cwd(), packageJsonPath)}: no private field`);
}
}

const pkgPath = process.argv[2];
if (!pkgPath) {
console.error('Usage: node scripts/validate-package-private-field.js <package-json-path>');
process.exit(1);
}

try {
validatePrivateField(path.resolve(process.cwd(), pkgPath));
} catch (err) {
console.error(err.message);
process.exit(1);
}