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

[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
pull merged 2 commits into nagyist:master from postgres-ai:master
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include:
- local: 'ui/packages/ce/.gitlab-ci.yml'
- local: 'ui/packages/shared/.gitlab-ci.yml'

.ui_checks: &ui_checks
rules:
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/ce/package.json
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@postgres.ai/ce",
"version": "1.0.0",
"version": "3.5.0",
"private": true,
"dependencies": {
"@craco/craco": "^6.4.3",
Expand Down
65 changes: 65 additions & 0 deletions ui/packages/shared/.gitlab-ci.yml
View file Open in desktop
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
18 changes: 14 additions & 4 deletions ui/packages/shared/package.json
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"name": "@postgres.ai/shared",
"version": "1.0.0",
"private": true,
"version": "3.5.0",
"scripts": {
"build": "tsc -p tsconfig.build.json && node scripts/copy-assets.js",
"pack": "node scripts/pack.js"
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"@babel/core": "^7.13.0",
"@craco/craco": "^7.0.0-alpha.7",
Expand All @@ -13,8 +19,6 @@
"@material-ui/styles": "^4.11.4",
"@monaco-editor/react": "^4.4.5",
"@mui/material": "^5.10.12",
"@postgres.ai/shared": "link:../shared",
"@postgres.ai/ce": "link:../ce",
"@types/node": "^12.20.33",
"@types/react": "^17.0.30",
"@types/react-dom": "^17.0.10",
Expand All @@ -41,5 +45,11 @@
"typescript": "^4.8.3",
"use-timer": "^2.0.1",
"yup": "^0.32.11"
},
"peerDependencies": {
"react": "^17.0.0 || ^18.0.0"
},
"devDependencies": {
"glob": "^11.0.2"
}
}
30 changes: 30 additions & 0 deletions ui/packages/shared/scripts/copy-assets.js
View file Open in desktop
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
View file Open in desktop
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();
6 changes: 3 additions & 3 deletions ui/packages/shared/styles/styles.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import { colors } from './colors'
import { theme } from './theme'

export const styles = {
export const styles: Record<string, any> = {
root: {
'min-height': '100%',
'minHeight': '100%',
width: '100%',
'z-index': 1,
'zIndex': 1,
position: 'relative',
[theme.breakpoints.down('sm')]: {
maxWidth: '100vw',
Expand Down
37 changes: 37 additions & 0 deletions ui/packages/shared/tsconfig.build.json
View file Open in desktop
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"
]
}
7 changes: 5 additions & 2 deletions ui/packages/shared/tsconfig.json
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"baseUrl": "."
"baseUrl": ".",
"paths": {
"@postgres.ai/shared/*": ["./*"]
}
},
"include": [
".",
"."
]
}
Loading

AltStyle によって変換されたページ (->オリジナル) /