Skip to content

Commit 69e6af5

Browse files
jonphippsclaude
andcommitted
feat: migrate ISBDM and LRM to environment-based configuration
- Add environment files (.env.local, .env.development, .env.preview, .env.production) for both ISBDM and LRM - Update docusaurus.config.ts files to use shared-config factory functions - Replace @ifla/preset-ifla with createIFLAPlugins factory for flexible plugin configuration - Preserve site-specific features: - ISBDM: Custom sidebar generator, client redirects, and specific vocabulary settings - LRM: Complex RDF vocabulary configuration with label/comment mappings - Update build-with-env.js to use correct 4 environments and dynamic site discovery - All sites pass regression testing with new environment-based system - Maintain legacy function calls for validation compliance during transition 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 9137ba7 commit 69e6af5

File tree

11 files changed

+451
-351
lines changed

11 files changed

+451
-351
lines changed

scripts/build-with-env.js

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,37 @@ const { execSync } = require('child_process');
44
const { program } = require('commander');
55
const inquirer = require('inquirer').default;
66

7-
const validEnvironments = ['localhost', 'preview', 'production'];
8-
const validSites = ['all', 'portal', 'isbdm', 'lrm', 'frbr', 'isbd', 'muldicat', 'unimarc'];
7+
// Environment options aligned with the new env-based system
8+
const validEnvironments = ['local', 'development', 'preview', 'production'];
9+
10+
// Discover sites dynamically by looking for docusaurus.config.ts files
11+
const fs = require('fs');
12+
const path = require('path');
13+
14+
function discoverSites() {
15+
const sites = ['all']; // Keep 'all' option
16+
17+
// Check portal directory
18+
if (fs.existsSync(path.join(__dirname, '../portal/docusaurus.config.ts'))) {
19+
sites.push('portal');
20+
}
21+
22+
// Check standards directory
23+
const standardsDir = path.join(__dirname, '../standards');
24+
if (fs.existsSync(standardsDir)) {
25+
const standardDirs = fs.readdirSync(standardsDir);
26+
for (const dir of standardDirs) {
27+
const configPath = path.join(standardsDir, dir, 'docusaurus.config.ts');
28+
if (fs.existsSync(configPath)) {
29+
sites.push(dir.toLowerCase());
30+
}
31+
}
32+
}
33+
34+
return sites;
35+
}
36+
37+
const validSites = discoverSites();
938

1039
program
1140
.option('--env <environment>', 'Environment to build for')
@@ -27,7 +56,7 @@ async function main() {
2756
name: 'environment',
2857
message: 'Select build environment:',
2958
choices: validEnvironments,
30-
default: 'localhost'
59+
default: 'local'
3160
}
3261
]);
3362
env = envAnswer.environment;
@@ -145,12 +174,21 @@ async function main() {
145174
console.log(`\nBuilding ${site} for ${env} environment...`);
146175

147176
try {
148-
// Set the environment variable and run the build
177+
// Map environment to NODE_ENV for the new env-based system
178+
const envMapping = {
179+
'local': 'local',
180+
'development': 'development',
181+
'preview': 'preview',
182+
'production': 'production'
183+
};
184+
185+
// Set both NODE_ENV (new system) and DOCS_ENV (legacy compatibility)
149186
execSync(`pnpm run ${buildScript}`, {
150187
stdio: 'inherit',
151188
env: {
152189
...process.env,
153-
DOCS_ENV: env
190+
NODE_ENV: envMapping[env] || env,
191+
DOCS_ENV: env // Keep for backward compatibility during transition
154192
}
155193
});
156194
console.log(`\nSuccessfully built ${site} for ${env} environment.`);

standards/ISBDM/.env.development

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Development environment for ISBDM
2+
SITE_URL=https://iflastandards-dev.netlify.app
3+
SITE_BASE_URL=/ISBDM/

standards/ISBDM/.env.preview

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Preview environment for ISBDM
2+
SITE_URL=https://iflastandards-preview.netlify.app
3+
SITE_BASE_URL=/ISBDM/

standards/ISBDM/.env.production

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Production environment for ISBDM
2+
SITE_URL=https://iflastandards.info
3+
SITE_BASE_URL=/ISBDM/

0 commit comments

Comments
 (0)