-
-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathlicense.js
More file actions
36 lines (31 loc) · 1.11 KB
/
license.js
File metadata and controls
36 lines (31 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const fs = require('fs');
const path = require('path');
const { log } = require('../utils/logger');
/**
* Set up MPL-2.0 license in the generated project.
*
* - Copies the LICENSE file from the CLI's own root
* - Sets "license": "MPL-2.0" in the project's package.json
*
* @param {string} projectPath - Path to the generated project
*/
function setupLicense(projectPath, spinner) {
spinner?.message('Adding MPL-2.0 license...');
// Copy LICENSE file from CLI root to generated project
const sourceLicense = path.join(__dirname, '..', '..', 'LICENSE');
const destLicense = path.join(projectPath, 'LICENSE');
if (fs.existsSync(sourceLicense)) {
fs.copyFileSync(sourceLicense, destLicense);
} else {
log.warning('LICENSE file not found in CLI - skipping LICENSE copy');
return;
}
// Set license field in package.json
const pkgPath = path.join(projectPath, 'package.json');
if (fs.existsSync(pkgPath)) {
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
pkg.license = 'MPL-2.0';
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
}
}
module.exports = { setupLicense };