chore: unify naming to @apigo.cc/state and upgrade version to 1.0.12
This commit is contained in:
parent
bfe18ca4a3
commit
e77a69d6cc
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "@web/state",
|
||||
"name": "@apigo.cc/state",
|
||||
"version": "1.0.12",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@web/state",
|
||||
"name": "@apigo.cc/state",
|
||||
"version": "1.0.12",
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.40.0",
|
||||
|
||||
39
package.json
39
package.json
@ -1,21 +1,22 @@
|
||||
{
|
||||
"name": "@web/state",
|
||||
"version": "1.0.13",
|
||||
"type": "module",
|
||||
"main": "dist/state.js",
|
||||
"module": "dist/state.js",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"test": "playwright test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.40.0",
|
||||
"@rollup/plugin-terser": "^1.0.0",
|
||||
"terser": "^5.47.1",
|
||||
"vite": "^5.0.0"
|
||||
}
|
||||
"name": "@apigo.cc/state",
|
||||
"version": "1.0.12",
|
||||
"type": "module",
|
||||
"main": "dist/state.js",
|
||||
"module": "dist/state.js",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"test": "playwright test",
|
||||
"pub": "node scripts/publish.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.40.0",
|
||||
"@rollup/plugin-terser": "^1.0.0",
|
||||
"terser": "^5.47.1",
|
||||
"vite": "^5.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
48
scripts/publish.js
Normal file
48
scripts/publish.js
Normal file
@ -0,0 +1,48 @@
|
||||
import { execSync } from 'child_process';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
try {
|
||||
// 1. 获取最新 tag
|
||||
let tag;
|
||||
try {
|
||||
tag = execSync('git describe --tags --abbrev=0', { encoding: 'utf8' }).trim();
|
||||
} catch (err) {
|
||||
throw new Error('Failed to find git tags. Please make sure the repository has tags (e.g., v1.0.0) before publishing.');
|
||||
}
|
||||
// 去掉 v 前缀
|
||||
const version = tag.startsWith('v') ? tag.slice(1) : tag;
|
||||
|
||||
console.log(`Latest git tag: ${tag}, Version to publish: ${version}`);
|
||||
|
||||
// 2. 读取并更新 package.json
|
||||
const pkgPath = path.join(__dirname, '../package.json');
|
||||
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
||||
|
||||
// 保持原有名称(如果已经带有 @apigo.cc/ 前缀)或替换前缀
|
||||
if (!pkg.name.startsWith('@apigo.cc/')) {
|
||||
const baseName = pkg.name.includes('/') ? pkg.name.split('/')[1] : pkg.name;
|
||||
pkg.name = `@apigo.cc/${baseName}`;
|
||||
}
|
||||
pkg.version = version;
|
||||
|
||||
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
||||
console.log(`Updated package.json: name=${pkg.name}, version=${pkg.version}`);
|
||||
|
||||
// 3. 构建
|
||||
console.log('Running build...');
|
||||
execSync('npm run build', { stdio: 'inherit', cwd: path.join(__dirname, '..') });
|
||||
|
||||
// 4. 发布
|
||||
console.log('Publishing to npm...');
|
||||
const args = process.argv.slice(2).join(' ');
|
||||
execSync(`npm publish --access public ${args}`, { stdio: 'inherit', cwd: path.join(__dirname, '..') });
|
||||
|
||||
console.log('Publish successful!');
|
||||
} catch (error) {
|
||||
console.error('Publish failed:', error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
@ -32,7 +32,7 @@ test('modular unit tests and benchmark', async ({ page }) => {
|
||||
const items = [];
|
||||
for(let i=0; i<1000; i++) items.push({val: 'item ' + i});
|
||||
window.state.benchItems = items;
|
||||
const { RefreshState } = await import('@web/state');
|
||||
const { RefreshState } = await import('@apigo.cc/state');
|
||||
RefreshState(document.documentElement);
|
||||
return performance.now() - start;
|
||||
});
|
||||
@ -51,7 +51,7 @@ test('modular unit tests and benchmark', async ({ page }) => {
|
||||
|
||||
// Extreme Data Test
|
||||
await page.evaluate(async () => {
|
||||
const { RefreshState } = await import('@web/state');
|
||||
const { RefreshState } = await import('@apigo.cc/state');
|
||||
document.body.innerHTML = '<div id="extreme" $each="state.extreme"></div>';
|
||||
window.state.extreme = null;
|
||||
RefreshState(document.getElementById('extreme'));
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": {
|
||||
"@web/state": "../src/index.js"
|
||||
"@apigo.cc/state": "../src/index.js"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user