Skip to content

Commit 41df2d1

Browse files
committed
Add version and processor for version to toml.
1 parent 2f4e441 commit 41df2d1

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed

prepare-deploy.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2025 Adobe. All rights reserved.
3+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License. You may obtain a copy
5+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
*
7+
* Unless required by applicable law or agreed to in writing, software distributed under
8+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
* OF ANY KIND, either express or implied. See the License for the specific language
10+
* governing permissions and limitations under the License.
11+
*/
12+
/* eslint-disable no-underscore-dangle */
13+
14+
import { dirname, resolve } from 'path';
15+
import { readFile, writeFile } from 'fs/promises';
16+
import { fileURLToPath } from 'url';
17+
18+
const __filename = fileURLToPath(import.meta.url);
19+
const __dirname = dirname(__filename);
20+
21+
try {
22+
let toml = await readFile(resolve(__dirname, 'wrangler.toml'), 'utf-8');
23+
const { version } = JSON.parse(await readFile(resolve(__dirname, 'package.json')));
24+
toml = toml.replaceAll('@@VERSION@@', version);
25+
await writeFile(resolve(__dirname, 'wrangler-versioned.toml'), toml, 'utf-8');
26+
} catch (e) {
27+
// eslint-disable-next-line no-console
28+
console.error(e);
29+
process.exitCode = 1;
30+
}

wrangler.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name = "da-admin"
22
main = "src/index.js"
33
compatibility_date = "2023-10-30"
44

5-
vars = { DA_COLLAB = "https://collab.da.live", DA_BUCKET_NAME = "da-content" }
5+
vars = { ENVIRONMENT = "production", DA_COLLAB = "https://collab.da.live", DA_BUCKET_NAME = "da-content", VERSION = "@@VERSION@@" }
66

7-
services = [
8-
{ binding = "dacollab", service = "da-collab" }
9-
]
7+
#services = [
8+
# { binding = "dacollab", service = "da-collab" }
9+
#]
1010

1111
kv_namespaces = [
1212
{ binding = "DA_AUTH", id = "f8978fd2270f4c4fbcc8c9f04248a034" },
@@ -20,11 +20,11 @@ r2_buckets = [
2020

2121

2222
[env.stage]
23-
vars = { ENVIRONMENT = "stage", DA_COLLAB = "https://collab.da.live", DA_BUCKET_NAME = "da-content-stage" }
23+
vars = { ENVIRONMENT = "stage", DA_COLLAB = "https://collab.da.live", DA_BUCKET_NAME = "da-content-stage", VERSION = "@@VERSION@@" }
2424

25-
services = [
26-
{ binding = "dacollab", service = "da-collab-stage" }
27-
]
25+
#services = [
26+
# { binding = "dacollab", service = "da-collab-stage" }
27+
#]
2828

2929
kv_namespaces = [
3030
{ binding = "DA_AUTH", id = "f5cc4d0150ac48d5b56948b5d147c77e" },
@@ -38,7 +38,7 @@ r2_buckets = [
3838

3939

4040
[env.dev]
41-
vars = { ENVIRONMENT = "dev", DA_COLLAB = "http://localhost:4711", DA_BUCKET_NAME = "da-content-dev" }
41+
vars = { ENVIRONMENT = "dev", DA_COLLAB = "http://localhost:4711", DA_BUCKET_NAME = "da-content-dev", VERSION = "@@VERSION@@" }
4242

4343
services = [
4444
{ binding = "dacollab", service = "da-collab-local" }

0 commit comments

Comments
 (0)