diff --git a/npm/package.json b/npm/package.json index c0662c6ebb..70496aba97 100644 --- a/npm/package.json +++ b/npm/package.json @@ -5,7 +5,8 @@ "gulp:app": "node run-gulp-script.js ../templates/app/aspnet-core", "gulp:module": "node run-gulp-script.js ../templates/module/aspnet-core", "ncu": "ncu", - "update:templates": "node abp-package-update-script.js ../templates" + "update:templates": "node abp-package-update-script.js ../templates", + "replace-with-tilde": "node replace-with-tilde.js" }, "devDependencies": { "@types/fs-extra": "^8.0.1", diff --git a/npm/preview-publish.ps1 b/npm/preview-publish.ps1 index ea4afd44d6..11c4ca0a21 100644 --- a/npm/preview-publish.ps1 +++ b/npm/preview-publish.ps1 @@ -24,7 +24,9 @@ $commands = ( "npm install", "npm run publish-packages -- --nextVersion $Version --preview", "cd ../../", - "yarn lerna publish $Version --no-push --yes --no-git-reset --no-commit-hooks --no-git-tag-version --force-publish --dist-tag preview --registry $Registry" + "yarn lerna version $Version --yes --no-commit-hooks --skip-git --force-publish", + "yarn replace-with-tilde", + "yarn lerna exec 'npm publish --registry $Registry --tag preview'" ) foreach ($command in $commands) { diff --git a/npm/publish.ps1 b/npm/publish.ps1 index a510527401..aaed04e6d4 100644 --- a/npm/publish.ps1 +++ b/npm/publish.ps1 @@ -16,7 +16,9 @@ $commands = ( "npm install", "npm run publish-packages -- --nextVersion $Version", "cd ../../", - "yarn lerna publish $Version --no-push --yes --no-git-reset --no-commit-hooks --no-git-tag-version --force-publish", + "yarn lerna version $Version --yes --no-commit-hooks --skip-git --force-publish", + "yarn replace-with-tilde", + "yarn lerna exec 'npm publish --registry https://registry.npmjs.org'", "yarn update:templates", "yarn gulp:app", "yarn gulp:module" diff --git a/npm/replace-with-tilde.js b/npm/replace-with-tilde.js new file mode 100644 index 0000000000..34438f4f5f --- /dev/null +++ b/npm/replace-with-tilde.js @@ -0,0 +1,28 @@ +const glob = require('glob'); +const fse = require('fs-extra'); + +function replace(filePath) { + const pkg = fse.readJsonSync(filePath); + + const { dependencies } = pkg; + + if (!dependencies) return; + + Object.keys(dependencies).forEach((key) => { + if (key.includes('@abp/') && key !== '@abp/utils') { + dependencies[key] = dependencies[key].replace('^', '~'); + } + }); + + fse.writeJsonSync(filePath, { ...pkg, dependencies }, { spaces: 2 }); +} + +glob('./packs/**/package.json', {}, (er, files) => { + files.forEach((path) => { + if (path.includes('node_modules')) { + return; + } + + replace(path); + }); +});