Skip to content
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
4 changes: 4 additions & 0 deletions .env.local
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which values here are required?

NEXT_PUBLIC_SCULPTOR_VERSION and NEXT_PUBLIC_PICTOR_VERSION are managed by the set-edition script. Are the other two variables required or what are they used for?

More importantly, we don't know the SAGITTARIUS_GRAPHQL_URL during build, so this variable must be overridable at runtime without rebuilding.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided to use a Nginx server for that

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
EDITION=ce
SAGITTARIUS_GRAPHQL_URL=http://localhost:3010/graphql
NEXT_PUBLIC_SCULPTOR_VERSION=0.0.0
NEXT_PUBLIC_PICTOR_VERSION=0.0.0-mvp.45
19 changes: 18 additions & 1 deletion edition.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// scripts/set-edition.mjs
import fs from "node:fs";
import path from "node:path";

Expand All @@ -23,3 +22,21 @@ tsconf.compilerOptions.paths['@edition/*'] = editionImports[edition];
fs.writeFileSync(tsconfig, JSON.stringify(tsconf, null, 2));

console.log(`[set-edition] current -> ${edition}`);

const lockPath = path.join(root, 'package-lock.json');
const lock = JSON.parse(fs.readFileSync(lockPath, 'utf-8'));
const sculptorVersion = (lock.packages && lock.packages[""].version) || '0.0.0';
const pictorVersion = (lock.packages && lock.packages["node_modules/@code0-tech/pictor"] && lock.packages["node_modules/@code0-tech/pictor"].version) || '0.0.0';

const envPath = path.join(root, '.env.local');
let envContent = '';
try {
envContent = fs.readFileSync(envPath, 'utf-8');
} catch (e) {}

envContent = envContent
.replace(/^NEXT_PUBLIC_SCULPTOR_VERSION=.*$/m, `NEXT_PUBLIC_SCULPTOR_VERSION=${sculptorVersion}`)
.replace(/^NEXT_PUBLIC_PICTOR_VERSION=.*$/m, `NEXT_PUBLIC_PICTOR_VERSION=${pictorVersion}`);

fs.writeFileSync(envPath, envContent.trim(), 'utf-8');
console.log(`[set-edition] Versions written to .env.local`);
4 changes: 0 additions & 4 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ const nextConfig: NextConfig = {
},
]
},
env: {
NEXT_PUBLIC_edition: EDITION,
NEXT_PUBLIC_pictorVersion: "11"
},
reactStrictMode: true,
reactCompiler: true,
turbopack: {
Expand Down
16 changes: 4 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "my-app",
"version": "0.1.0",
"name": "@code0-tech/sculptor",
"version": "0.0.0",
"private": true,
"scripts": {
"predev": "node edition.mjs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const ApplicationSettingsPage: React.FC = () => {
<Text size={"md"} hierarchy={"primary"}>Sculptor version</Text>
<Text size={"md"} hierarchy={"tertiary"}>Version of this application</Text>
</Flex>
<Badge color={"info"}>v0.0.0-mvp.1</Badge>
<Badge color={"info"}>{process.env.NEXT_PUBLIC_SCULPTOR_VERSION}</Badge>
</Flex>
</CardSection>

Expand All @@ -140,7 +140,7 @@ export const ApplicationSettingsPage: React.FC = () => {
library</Text>
</Flex>
<Badge
color={"info"}>v0.0.0-mvp.10</Badge>
color={"info"}>{process.env.NEXT_PUBLIC_PICTOR_VERSION}</Badge>
</Flex>
</CardSection>
<CardSection border>
Expand Down