2024-05-03 17:11:56 +00:00
|
|
|
import adapter from '@sveltejs/adapter-static';
|
|
|
|
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
2024-07-03 20:45:37 +00:00
|
|
|
import * as child_process from 'node:child_process';
|
|
|
|
import { readFileSync } from 'fs';
|
|
|
|
import { join } from 'path';
|
|
|
|
|
|
|
|
// Helper function to execute shell commands
|
|
|
|
function execSync(cmd) {
|
|
|
|
return child_process.execSync(cmd).toString().trim();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read version from package.json
|
|
|
|
const packageJsonPath = join(process.cwd(), 'package.json');
|
|
|
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
|
|
const VERSION = packageJson.version;
|
|
|
|
|
|
|
|
// Retrieve current branch
|
|
|
|
const BRANCH = execSync('git rev-parse --abbrev-ref HEAD');
|
|
|
|
|
|
|
|
// Retrieve current tag if it exists
|
|
|
|
const RELEASE_TAG = execSync('git tag -l --points-at HEAD');
|
|
|
|
|
|
|
|
// Generate version suffix
|
|
|
|
const commitCount = execSync('git rev-list --count HEAD');
|
|
|
|
const shortCommitHash = execSync('git show --no-patch --no-notes --pretty="%h" HEAD');
|
|
|
|
const VERSION_SUFFIX = `-beta.${commitCount}.${shortCommitHash}`;
|
|
|
|
|
|
|
|
// Determine branch-specific values
|
|
|
|
let TAG_BRANCH = `.${BRANCH}`;
|
|
|
|
|
|
|
|
if (BRANCH === 'HEAD' || BRANCH === 'main') {
|
|
|
|
TAG_BRANCH = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Determine final tag
|
|
|
|
let TAG = `${VERSION}${VERSION_SUFFIX}${TAG_BRANCH}`;
|
|
|
|
if (RELEASE_TAG) {
|
|
|
|
TAG = RELEASE_TAG;
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log('Building with tag', TAG);
|
2024-05-03 17:11:56 +00:00
|
|
|
|
|
|
|
/** @type {import('@sveltejs/kit').Config} */
|
|
|
|
const config = {
|
|
|
|
preprocess: vitePreprocess(),
|
|
|
|
kit: {
|
2024-07-03 20:45:37 +00:00
|
|
|
version: {
|
|
|
|
name: TAG
|
|
|
|
},
|
2024-05-03 17:11:56 +00:00
|
|
|
// paths: {
|
|
|
|
// base: '/'
|
|
|
|
// },
|
|
|
|
// trailingSlash: 'always',
|
|
|
|
adapter: adapter()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default config;
|