Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optionalDependencies support for deploy #59

Merged
merged 2 commits into from
Feb 23, 2024
Merged
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cocos/ccbuild",
"version": "2.2.6",
"version": "2.2.7",
"description": "The next generation of build tool for Cocos engine.",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down
12 changes: 12 additions & 0 deletions scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const pkgName2Main = {};
const pkgName2Types = {};
const filesToCopy = [];
const allDeps = {};
const allOptionalDeps = {};

pkgFileList.forEach(pkgFile => {
const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf8'));
const pkgName = pkg.name;
Expand Down Expand Up @@ -56,6 +58,15 @@ pkgFileList.forEach(pkgFile => {
allDeps[dep] = depVersion;
}

for (const dep in pkg.optionalDependencies) {
const depVersion = pkg.optionalDependencies[dep];
if (dep in allOptionalDeps && allOptionalDeps[dep] !== depVersion) {
console.warn(`optional package '${pkgName}' has different dep version of package '${dep}', which is '${depVersion}'`);
continue;
}
allOptionalDeps[dep] = depVersion;
}

});

// copy files
Expand Down Expand Up @@ -132,6 +143,7 @@ console.log('generate package.json');
const rootPkgFile = ps.join(rootDir, 'package.json');
const rootPkg = JSON.parse(fs.readFileSync(rootPkgFile, 'utf8'));
rootPkg.dependencies = allDeps;
rootPkg.optionalDependencies = allOptionalDeps;
delete rootPkg.devDependencies;
delete rootPkg.scripts;
for (const dep in rootPkg.dependencies) {
Expand Down
Loading