This repository has been archived by the owner on Jul 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
57 additions
and
41 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
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,8 @@ | ||
const { readCompat, PACKAGE_DIR } = require("./utils"); | ||
|
||
async function runCheck() { | ||
await readCompat(PACKAGE_DIR) | ||
console.log('=== check syntax success') | ||
} | ||
|
||
runCheck(); |
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,41 @@ | ||
const assert = require('assert'); | ||
const path = require('path'); | ||
const fs = require('fs/promises'); | ||
|
||
/** | ||
* @param {string} name | ||
* @returns {[string, string]} | ||
*/ | ||
function splitPackageName(name) { | ||
return name.split('@') | ||
} | ||
|
||
/** | ||
* @param {string} dir | ||
*/ | ||
async function readCompat(dir) { | ||
const list = await fs.readdir(dir); | ||
return list.map(item => { | ||
const [name, version] = splitPackageName(item); | ||
const abs = path.resolve(dir, item, 'package.json'); | ||
const info = require(abs).rspack; | ||
assert(typeof name === 'string', 'Please add the name for the supported plugin') | ||
assert(typeof version === 'string', `Please add the support version of \`${item}\``) | ||
assert(typeof info.version === 'string', 'Please add the minimal version of rspack supported in package.json') | ||
return { | ||
name, | ||
version, | ||
rspackVersion: info.version, | ||
path: path.relative(ROOT_DIR, path.resolve(dir, item)) | ||
} | ||
}) | ||
} | ||
|
||
const ROOT_DIR = path.resolve(__dirname, '..') | ||
const PACKAGE_DIR = path.resolve(ROOT_DIR, 'packages'); | ||
|
||
module.exports = { | ||
readCompat, | ||
ROOT_DIR, | ||
PACKAGE_DIR | ||
} |