forked from postgres-ai/database-lab-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
[pull] master from postgres-ai:master #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -13,3 +13,5 @@ engine/bin/ | |
/engine/configs/ci_checker.yml | ||
|
||
engine/meta | ||
|
||
ui/packages/shared/dist/ |
1 change: 1 addition & 0 deletions
ui/.gitlab-ci.yml
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
ui/packages/ce/package.json
This file contains hidden or 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
65 changes: 65 additions & 0 deletions
ui/packages/shared/.gitlab-ci.yml
This file contains hidden or 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,65 @@ | ||
.only_ui_feature: &only_ui_feature | ||
rules: | ||
- if: $CI_PIPELINE_SOURCE == "merge_request_event" | ||
|
||
.only_ui_tag_release: &only_ui_tag_release | ||
rules: | ||
- if: $CI_COMMIT_TAG =~ /^v[a-zA-Z0-9_.-]*/ | ||
|
||
.shared_base: &shared_base | ||
image: node:lts-alpine | ||
allow_failure: true | ||
cache: | ||
key: "$CI_COMMIT_REF_SLUG" | ||
paths: | ||
- .pnpm-store | ||
before_script: | ||
- apk add --no-cache rsync jq | ||
- corepack enable | ||
- corepack prepare pnpm@8.9.2 --activate | ||
- pnpm config set store-dir .pnpm-store | ||
- pnpm --dir ui/packages/shared install --frozen-lockfile | ||
|
||
publish-shared-preview: | ||
<<: [*shared_base, *only_ui_feature] | ||
stage: build | ||
script: | ||
- cd ui/packages/shared | ||
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc | ||
|
||
# Get base version from package.json (strip any -pr or other suffix) | ||
- BASE_VERSION=$(jq -r .version package.json) | ||
- BASE_VERSION=${BASE_VERSION%%-*} | ||
- export PREID="pr-${CI_MERGE_REQUEST_IID:-preview}" | ||
|
||
# Detect next available patch for same PR | ||
- EXISTING_TAGS=$(npm view @postgres.ai/shared versions --json | jq -r '.[]' | grep "^${BASE_VERSION}-${PREID}" || true) | ||
- COUNT=$(echo "$EXISTING_TAGS" | wc -l | xargs) | ||
- if [ "$COUNT" -eq 0 ]; then VERSION="${BASE_VERSION}-${PREID}"; else VERSION="${BASE_VERSION}-${PREID}.${COUNT}"; fi | ||
- echo "Publishing version $VERSION" | ||
- npm version "$VERSION" --no-git-tag-version | ||
|
||
# Build and pack | ||
- pnpm run pack | ||
|
||
# Publish .tgz archive | ||
- TARBALL=$(ls postgres.ai-shared-*.tgz) | ||
- pnpm publish "$TARBALL" --no-git-checks --tag "$PREID" | ||
|
||
publish-shared-release: | ||
<<: [*shared_base, *only_ui_tag_release] | ||
stage: build | ||
script: | ||
- cd ui/packages/shared | ||
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc | ||
|
||
# Extract version from tag (remove leading "v") | ||
- export VERSION=${CI_COMMIT_TAG#"v"} | ||
|
||
# Build and pack | ||
- npm version "$VERSION" --no-git-tag-version | ||
- pnpm run pack | ||
|
||
# Publish | ||
- TARBALL=$(ls postgres.ai-shared-*.tgz) | ||
- pnpm publish "$TARBALL" --no-git-checks |
This file contains hidden or 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
30 changes: 30 additions & 0 deletions
ui/packages/shared/scripts/copy-assets.js
This file contains hidden or 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,30 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const glob = require('glob'); | ||
|
||
const OUT_DIR = 'dist'; | ||
|
||
const PATTERNS = [ | ||
'**/*.scss', | ||
'**/*.module.scss', | ||
'**/*.json', | ||
'react-app-env.d.ts', | ||
]; | ||
|
||
const files = PATTERNS.flatMap(pattern => | ||
glob.sync(pattern, { | ||
cwd: '.', | ||
ignore: ['node_modules/**', 'dist/**'], | ||
nodir: true, | ||
}) | ||
); | ||
|
||
files.forEach((file) => { | ||
const from = path.resolve(file); | ||
const to = path.join(OUT_DIR, file); | ||
const dir = path.dirname(to); | ||
fs.mkdirSync(dir, { recursive: true }); | ||
fs.copyFileSync(from, to); | ||
}); | ||
|
||
console.log(`✅ Copied ${files.length} assets to dist`); |
70 changes: 70 additions & 0 deletions
ui/packages/shared/scripts/pack.js
This file contains hidden or 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,70 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { execSync } = require('child_process'); | ||
|
||
const TMP_DIR = 'build-tmp'; | ||
const DIST_DIR = 'dist'; | ||
const PACKAGE_JSON = 'package.json'; | ||
|
||
function cleanTmp() { | ||
if (fs.existsSync(TMP_DIR)) { | ||
fs.rmSync(TMP_DIR, { recursive: true, force: true }); | ||
} | ||
} | ||
|
||
function run(cmd, options = {}) { | ||
console.log(`$ ${cmd}`); | ||
execSync(cmd, { stdio: 'inherit', ...options }); | ||
} | ||
|
||
function copyDistToTmp() { | ||
run(`rsync -a ${DIST_DIR}/ ${TMP_DIR}/`); | ||
} | ||
|
||
function copyExtraFiles() { | ||
const extras = ['react-app-env.d.ts']; | ||
extras.forEach((file) => { | ||
if (fs.existsSync(file)) { | ||
fs.copyFileSync(file, path.join(TMP_DIR, file)); | ||
} | ||
}); | ||
} | ||
|
||
function sanitizePackageJson() { | ||
const original = JSON.parse(fs.readFileSync(PACKAGE_JSON, 'utf8')); | ||
const cleaned = { | ||
name: original.name, | ||
version: original.version, | ||
description: original.description, | ||
author: original.author, | ||
license: original.license, | ||
main: original.main || 'index.js', | ||
types: original.types || 'index.d.ts', | ||
peerDependencies: original.peerDependencies, | ||
dependencies: original.dependencies, | ||
}; | ||
|
||
fs.writeFileSync( | ||
path.join(TMP_DIR, 'package.json'), | ||
JSON.stringify(cleaned, null, 2), | ||
'utf8' | ||
); | ||
} | ||
|
||
function pack() { | ||
run('npm pack', { cwd: TMP_DIR }); | ||
const tarball = fs.readdirSync(TMP_DIR).find(f => f.endsWith('.tgz')); | ||
fs.renameSync(path.join(TMP_DIR, tarball), path.join('.', tarball)); | ||
console.log(`✅ Packed to ./${tarball}`); | ||
} | ||
|
||
function buildTmpAndPack() { | ||
cleanTmp(); | ||
run('pnpm run build'); | ||
copyDistToTmp(); | ||
sanitizePackageJson(); | ||
pack(); | ||
cleanTmp(); | ||
} | ||
|
||
buildTmpAndPack(); |
This file contains hidden or 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
37 changes: 37 additions & 0 deletions
ui/packages/shared/tsconfig.build.json
This file contains hidden or 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,37 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"outDir": "dist", | ||
"declaration": true, | ||
"emitDeclarationOnly": false, | ||
"noEmit": false, | ||
"module": "esnext", | ||
"target": "es2019", | ||
"moduleResolution": "node", | ||
"jsx": "react-jsx", | ||
"resolveJsonModule": true, | ||
"esModuleInterop": true | ||
}, | ||
"include": [ | ||
"components/**/*", | ||
"config/**/*", | ||
"helpers/**/*", | ||
"hooks/**/*", | ||
"icons/**/*", | ||
"pages/**/*", | ||
"stores/**/*", | ||
"styles/**/*", | ||
"types/**/*", | ||
"utils/**/*", | ||
"react-app-env.d.ts", | ||
], | ||
"exclude": [ | ||
"node_modules", | ||
"dist", | ||
"meta.json", | ||
"craco.config.js", | ||
"**/*.test.ts", | ||
"**/*.test.tsx" | ||
] | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.