Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit97b719a

Browse files
author
Bogdan Tsechoev
committed
Merge branch 'npm_package' into 'master'
feat(ui/shared): add npm publishing support for shared packageSee merge request postgres-ai/database-lab!1027
2 parents9596cba +772e463 commit97b719a

File tree

11 files changed

+343
-21
lines changed

11 files changed

+343
-21
lines changed

‎.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ engine/bin/
1313
/engine/configs/ci_checker.yml
1414

1515
engine/meta
16+
17+
ui/packages/shared/dist/

‎ui/.gitlab-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
include:
22
-local:'ui/packages/ce/.gitlab-ci.yml'
3+
-local:'ui/packages/shared/.gitlab-ci.yml'
34

45
.ui_checks:&ui_checks
56
rules:

‎ui/packages/ce/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"@postgres.ai/ce",
3-
"version":"1.0.0",
3+
"version":"3.5.0",
44
"private":true,
55
"dependencies": {
66
"@craco/craco":"^6.4.3",

‎ui/packages/shared/.gitlab-ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
.only_ui_feature:&only_ui_feature
2+
rules:
3+
-if:$CI_PIPELINE_SOURCE == "merge_request_event"
4+
5+
.only_ui_tag_release:&only_ui_tag_release
6+
rules:
7+
-if:$CI_COMMIT_TAG =~ /^v[a-zA-Z0-9_.-]*/
8+
9+
.shared_base:&shared_base
10+
image:node:lts-alpine
11+
allow_failure:true
12+
cache:
13+
key:"$CI_COMMIT_REF_SLUG"
14+
paths:
15+
-.pnpm-store
16+
before_script:
17+
-apk add --no-cache rsync jq
18+
-corepack enable
19+
-corepack prepare pnpm@8.9.2 --activate
20+
-pnpm config set store-dir .pnpm-store
21+
-pnpm --dir ui/packages/shared install --frozen-lockfile
22+
23+
publish-shared-preview:
24+
<<:[*shared_base, *only_ui_feature]
25+
stage:build
26+
script:
27+
-cd ui/packages/shared
28+
-echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
29+
30+
# Get base version from package.json (strip any -pr or other suffix)
31+
-BASE_VERSION=$(jq -r .version package.json)
32+
-BASE_VERSION=${BASE_VERSION%%-*}
33+
-export PREID="pr-${CI_MERGE_REQUEST_IID:-preview}"
34+
35+
# Detect next available patch for same PR
36+
-EXISTING_TAGS=$(npm view @postgres.ai/shared versions --json | jq -r '.[]' | grep "^${BASE_VERSION}-${PREID}" || true)
37+
-COUNT=$(echo "$EXISTING_TAGS" | wc -l | xargs)
38+
-if [ "$COUNT" -eq 0 ]; then VERSION="${BASE_VERSION}-${PREID}"; else VERSION="${BASE_VERSION}-${PREID}.${COUNT}"; fi
39+
-echo "Publishing version $VERSION"
40+
-npm version "$VERSION" --no-git-tag-version
41+
42+
# Build and pack
43+
-pnpm run pack
44+
45+
# Publish .tgz archive
46+
-TARBALL=$(ls postgres.ai-shared-*.tgz)
47+
-pnpm publish "$TARBALL" --no-git-checks --tag "$PREID"
48+
49+
publish-shared-release:
50+
<<:[*shared_base, *only_ui_tag_release]
51+
stage:build
52+
script:
53+
-cd ui/packages/shared
54+
-echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
55+
56+
# Extract version from tag (remove leading "v")
57+
-export VERSION=${CI_COMMIT_TAG#"v"}
58+
59+
# Build and pack
60+
-npm version "$VERSION" --no-git-tag-version
61+
-pnpm run pack
62+
63+
# Publish
64+
-TARBALL=$(ls postgres.ai-shared-*.tgz)
65+
-pnpm publish "$TARBALL" --no-git-checks

‎ui/packages/shared/package.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
{
22
"name":"@postgres.ai/shared",
3-
"version":"1.0.0",
4-
"private":true,
3+
"version":"3.5.0",
4+
"scripts": {
5+
"build":"tsc -p tsconfig.build.json && node scripts/copy-assets.js",
6+
"pack":"node scripts/pack.js"
7+
},
8+
"publishConfig": {
9+
"access":"public"
10+
},
511
"dependencies": {
612
"@babel/core":"^7.13.0",
713
"@craco/craco":"^7.0.0-alpha.7",
@@ -13,8 +19,6 @@
1319
"@material-ui/styles":"^4.11.4",
1420
"@monaco-editor/react":"^4.4.5",
1521
"@mui/material":"^5.10.12",
16-
"@postgres.ai/shared":"link:../shared",
17-
"@postgres.ai/ce":"link:../ce",
1822
"@types/node":"^12.20.33",
1923
"@types/react":"^17.0.30",
2024
"@types/react-dom":"^17.0.10",
@@ -41,5 +45,11 @@
4145
"typescript":"^4.8.3",
4246
"use-timer":"^2.0.1",
4347
"yup":"^0.32.11"
48+
},
49+
"peerDependencies": {
50+
"react":"^17.0.0 || ^18.0.0"
51+
},
52+
"devDependencies": {
53+
"glob":"^11.0.2"
4454
}
4555
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
constfs=require('fs');
2+
constpath=require('path');
3+
constglob=require('glob');
4+
5+
constOUT_DIR='dist';
6+
7+
constPATTERNS=[
8+
'**/*.scss',
9+
'**/*.module.scss',
10+
'**/*.json',
11+
'react-app-env.d.ts',
12+
];
13+
14+
constfiles=PATTERNS.flatMap(pattern=>
15+
glob.sync(pattern,{
16+
cwd:'.',
17+
ignore:['node_modules/**','dist/**'],
18+
nodir:true,
19+
})
20+
);
21+
22+
files.forEach((file)=>{
23+
constfrom=path.resolve(file);
24+
constto=path.join(OUT_DIR,file);
25+
constdir=path.dirname(to);
26+
fs.mkdirSync(dir,{recursive:true});
27+
fs.copyFileSync(from,to);
28+
});
29+
30+
console.log(`✅ Copied${files.length} assets to dist`);

‎ui/packages/shared/scripts/pack.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
constfs=require('fs');
2+
constpath=require('path');
3+
const{ execSync}=require('child_process');
4+
5+
constTMP_DIR='build-tmp';
6+
constDIST_DIR='dist';
7+
constPACKAGE_JSON='package.json';
8+
9+
functioncleanTmp(){
10+
if(fs.existsSync(TMP_DIR)){
11+
fs.rmSync(TMP_DIR,{recursive:true,force:true});
12+
}
13+
}
14+
15+
functionrun(cmd,options={}){
16+
console.log(`$${cmd}`);
17+
execSync(cmd,{stdio:'inherit', ...options});
18+
}
19+
20+
functioncopyDistToTmp(){
21+
run(`rsync -a${DIST_DIR}/${TMP_DIR}/`);
22+
}
23+
24+
functioncopyExtraFiles(){
25+
constextras=['react-app-env.d.ts'];
26+
extras.forEach((file)=>{
27+
if(fs.existsSync(file)){
28+
fs.copyFileSync(file,path.join(TMP_DIR,file));
29+
}
30+
});
31+
}
32+
33+
functionsanitizePackageJson(){
34+
constoriginal=JSON.parse(fs.readFileSync(PACKAGE_JSON,'utf8'));
35+
constcleaned={
36+
name:original.name,
37+
version:original.version,
38+
description:original.description,
39+
author:original.author,
40+
license:original.license,
41+
main:original.main||'index.js',
42+
types:original.types||'index.d.ts',
43+
peerDependencies:original.peerDependencies,
44+
dependencies:original.dependencies,
45+
};
46+
47+
fs.writeFileSync(
48+
path.join(TMP_DIR,'package.json'),
49+
JSON.stringify(cleaned,null,2),
50+
'utf8'
51+
);
52+
}
53+
54+
functionpack(){
55+
run('npm pack',{cwd:TMP_DIR});
56+
consttarball=fs.readdirSync(TMP_DIR).find(f=>f.endsWith('.tgz'));
57+
fs.renameSync(path.join(TMP_DIR,tarball),path.join('.',tarball));
58+
console.log(`✅ Packed to ./${tarball}`);
59+
}
60+
61+
functionbuildTmpAndPack(){
62+
cleanTmp();
63+
run('pnpm run build');
64+
copyDistToTmp();
65+
sanitizePackageJson();
66+
pack();
67+
cleanTmp();
68+
}
69+
70+
buildTmpAndPack();

‎ui/packages/shared/styles/styles.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import{colors}from'./colors'
99
import{theme}from'./theme'
1010

11-
exportconststyles={
11+
exportconststyles:Record<string,any>={
1212
root:{
13-
'min-height':'100%',
13+
'minHeight':'100%',
1414
width:'100%',
15-
'z-index':1,
15+
'zIndex':1,
1616
position:'relative',
1717
[theme.breakpoints.down('sm')]:{
1818
maxWidth:'100vw',
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"extends":"./tsconfig.json",
3+
"compilerOptions": {
4+
"rootDir":".",
5+
"outDir":"dist",
6+
"declaration":true,
7+
"emitDeclarationOnly":false,
8+
"noEmit":false,
9+
"module":"esnext",
10+
"target":"es2019",
11+
"moduleResolution":"node",
12+
"jsx":"react-jsx",
13+
"resolveJsonModule":true,
14+
"esModuleInterop":true
15+
},
16+
"include": [
17+
"components/**/*",
18+
"config/**/*",
19+
"helpers/**/*",
20+
"hooks/**/*",
21+
"icons/**/*",
22+
"pages/**/*",
23+
"stores/**/*",
24+
"styles/**/*",
25+
"types/**/*",
26+
"utils/**/*",
27+
"react-app-env.d.ts",
28+
],
29+
"exclude": [
30+
"node_modules",
31+
"dist",
32+
"meta.json",
33+
"craco.config.js",
34+
"**/*.test.ts",
35+
"**/*.test.tsx"
36+
]
37+
}

‎ui/packages/shared/tsconfig.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
"isolatedModules":true,
2020
"noEmit":true,
2121
"jsx":"react-jsx",
22-
"baseUrl":"."
22+
"baseUrl":".",
23+
"paths": {
24+
"@postgres.ai/shared/*": ["./*"]
25+
}
2326
},
2427
"include": [
25-
".",
28+
"."
2629
]
2730
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp