forked from alibaba/ice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support version check between @ice/app and @ice/runtime (alibab…
…a#6151) * feat: support version check between @ice/app and @ice/runtime * fix: update lock
- Loading branch information
Showing
6 changed files
with
82 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@ice/runtime': patch | ||
'@ice/app': patch | ||
--- | ||
|
||
feat: support version check between @ice/app and @ice/runtime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { createRequire } from 'module'; | ||
import fs from 'fs'; | ||
import semver from 'semver'; | ||
|
||
const require = createRequire(import.meta.url); | ||
// Only change this when you release a version which break the usage of runtime generation. | ||
// TODO modify valid version to 1.2.0 after version is updated, otherwise it will cause build error. | ||
const RUNTIME_VALID_VERSION = '>=1.1.0'; | ||
try { | ||
// @ice/runtime has defined package.json exports, so we can use require.resolve to get the package.json path. | ||
const packageJsonPath = require.resolve('@ice/runtime/package.json'); | ||
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); | ||
if (!semver.satisfies(pkg.version, RUNTIME_VALID_VERSION)) { | ||
console.log(`Detect @ice/runtime version is ${pkg.version}, Please update @ice/runtime to ${RUNTIME_VALID_VERSION}`); | ||
// Break the process while @ice/runtime version is not valid. | ||
process.exit(1); | ||
} | ||
} catch (e) { | ||
// Ignore errors while @ice/runtime is not installed. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { createRequire } from 'module'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import semver from 'semver'; | ||
|
||
const require = createRequire(import.meta.url); | ||
// Only change this when you release a version which break the usage of runtime generation. | ||
// TODO modify valid version to 3.2.0 after version is updated, otherwise it will cause build error. | ||
const ICE_VALID_VERSION = '>=3.1.6'; | ||
try { | ||
const packagePath = require.resolve('@ice/app', { paths: [process.cwd()] }); | ||
const packageJsonPath = path.join(path.dirname(packagePath),'../package.json'); | ||
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); | ||
if (!semver.satisfies(pkg.version, ICE_VALID_VERSION)) { | ||
console.log(`Detect @ice/app version is ${pkg.version}, Please update @ice/app to ${ICE_VALID_VERSION}`); | ||
// Break the process while @ice/app version is not valid. | ||
process.exit(1); | ||
} | ||
} catch (e) { | ||
// Ignore errors while @ice/app is not installed. | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.