mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
support process.env.USE_LINKED_SHARED
This commit is contained in:
parent
0c50f56337
commit
0c2964183a
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import { webcrypto as crypto } from "crypto"
|
import { webcrypto as crypto } from "crypto"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { registerBaseAliases } from "linebridge/dist/server"
|
import { registerBaseAliases } from "linebridge/dist/server"
|
||||||
@ -18,6 +17,11 @@ const customAliases = {
|
|||||||
|
|
||||||
if (!global.isProduction) {
|
if (!global.isProduction) {
|
||||||
customAliases["comty.js"] = path.resolve(__dirname, "../../comty.js/src")
|
customAliases["comty.js"] = path.resolve(__dirname, "../../comty.js/src")
|
||||||
|
|
||||||
|
customAliases["@shared-classes"] = path.resolve(__dirname, "shared-classes")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.env.USE_LINKED_SHARED) {
|
||||||
customAliases["@shared-classes"] = path.resolve(__dirname, "shared-classes")
|
customAliases["@shared-classes"] = path.resolve(__dirname, "shared-classes")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +73,9 @@ async function main() {
|
|||||||
|
|
||||||
// inject to process.env
|
// inject to process.env
|
||||||
secrets.forEach((secret) => {
|
secrets.forEach((secret) => {
|
||||||
|
if (!(secret.secretName in process.env)) {
|
||||||
process.env[secret.secretName] = secret.secretValue
|
process.env[secret.secretName] = secret.secretValue
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +88,7 @@ async function main() {
|
|||||||
if (typeof instance.server.close === "function") {
|
if (typeof instance.server.close === "function") {
|
||||||
instance.server.close()
|
instance.server.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -90,6 +97,7 @@ async function main() {
|
|||||||
if (typeof instance.server.close === "function") {
|
if (typeof instance.server.close === "function") {
|
||||||
instance.server.close()
|
instance.server.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import { webcrypto as crypto } from "crypto"
|
import { webcrypto as crypto } from "crypto"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { registerBaseAliases } from "linebridge/dist/server"
|
import { registerBaseAliases } from "linebridge/dist/server"
|
||||||
@ -18,6 +17,11 @@ const customAliases = {
|
|||||||
|
|
||||||
if (!global.isProduction) {
|
if (!global.isProduction) {
|
||||||
customAliases["comty.js"] = path.resolve(__dirname, "../../comty.js/src")
|
customAliases["comty.js"] = path.resolve(__dirname, "../../comty.js/src")
|
||||||
|
|
||||||
|
customAliases["@shared-classes"] = path.resolve(__dirname, "shared-classes")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.env.USE_LINKED_SHARED) {
|
||||||
customAliases["@shared-classes"] = path.resolve(__dirname, "shared-classes")
|
customAliases["@shared-classes"] = path.resolve(__dirname, "shared-classes")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +73,9 @@ async function main() {
|
|||||||
|
|
||||||
// inject to process.env
|
// inject to process.env
|
||||||
secrets.forEach((secret) => {
|
secrets.forEach((secret) => {
|
||||||
|
if (!(secret.secretName in process.env)) {
|
||||||
process.env[secret.secretName] = secret.secretValue
|
process.env[secret.secretName] = secret.secretValue
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +88,7 @@ async function main() {
|
|||||||
if (typeof instance.server.close === "function") {
|
if (typeof instance.server.close === "function") {
|
||||||
instance.server.close()
|
instance.server.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -90,6 +97,7 @@ async function main() {
|
|||||||
if (typeof instance.server.close === "function") {
|
if (typeof instance.server.close === "function") {
|
||||||
instance.server.close()
|
instance.server.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import { webcrypto as crypto } from "crypto"
|
import { webcrypto as crypto } from "crypto"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { registerBaseAliases } from "linebridge/dist/server"
|
import { registerBaseAliases } from "linebridge/dist/server"
|
||||||
@ -18,6 +17,11 @@ const customAliases = {
|
|||||||
|
|
||||||
if (!global.isProduction) {
|
if (!global.isProduction) {
|
||||||
customAliases["comty.js"] = path.resolve(__dirname, "../../comty.js/src")
|
customAliases["comty.js"] = path.resolve(__dirname, "../../comty.js/src")
|
||||||
|
|
||||||
|
customAliases["@shared-classes"] = path.resolve(__dirname, "shared-classes")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.env.USE_LINKED_SHARED) {
|
||||||
customAliases["@shared-classes"] = path.resolve(__dirname, "shared-classes")
|
customAliases["@shared-classes"] = path.resolve(__dirname, "shared-classes")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +73,9 @@ async function main() {
|
|||||||
|
|
||||||
// inject to process.env
|
// inject to process.env
|
||||||
secrets.forEach((secret) => {
|
secrets.forEach((secret) => {
|
||||||
|
if (!(secret.secretName in process.env)) {
|
||||||
process.env[secret.secretName] = secret.secretValue
|
process.env[secret.secretName] = secret.secretValue
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +88,7 @@ async function main() {
|
|||||||
if (typeof instance.server.close === "function") {
|
if (typeof instance.server.close === "function") {
|
||||||
instance.server.close()
|
instance.server.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -90,6 +97,7 @@ async function main() {
|
|||||||
if (typeof instance.server.close === "function") {
|
if (typeof instance.server.close === "function") {
|
||||||
instance.server.close()
|
instance.server.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -17,6 +17,11 @@ const customAliases = {
|
|||||||
|
|
||||||
if (!global.isProduction) {
|
if (!global.isProduction) {
|
||||||
customAliases["comty.js"] = path.resolve(__dirname, "../../comty.js/src")
|
customAliases["comty.js"] = path.resolve(__dirname, "../../comty.js/src")
|
||||||
|
|
||||||
|
customAliases["@shared-classes"] = path.resolve(__dirname, "shared-classes")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.env.USE_LINKED_SHARED) {
|
||||||
customAliases["@shared-classes"] = path.resolve(__dirname, "shared-classes")
|
customAliases["@shared-classes"] = path.resolve(__dirname, "shared-classes")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,16 +65,12 @@ import API from "./api"
|
|||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
if (process.env.INFISICAL_TOKEN) {
|
if (process.env.INFISICAL_TOKEN) {
|
||||||
console.log("🔑 Fetching secrets from Infisical...")
|
|
||||||
|
|
||||||
const client = new infisical({
|
const client = new infisical({
|
||||||
token: process.env.INFISICAL_TOKEN,
|
token: process.env.INFISICAL_TOKEN,
|
||||||
})
|
})
|
||||||
|
|
||||||
const secrets = await client.getAllSecrets()
|
const secrets = await client.getAllSecrets()
|
||||||
|
|
||||||
console.log("🔑 Injecting secrets to process.env...",)
|
|
||||||
|
|
||||||
// inject to process.env
|
// inject to process.env
|
||||||
secrets.forEach((secret) => {
|
secrets.forEach((secret) => {
|
||||||
if (!(secret.secretName in process.env)) {
|
if (!(secret.secretName in process.env)) {
|
||||||
@ -78,13 +79,6 @@ async function main() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// transform "undefined" or "null" envs to undefined
|
|
||||||
Object.keys(process.env).forEach((key) => {
|
|
||||||
if (process.env[key] === "undefined" || process.env[key] === "null") {
|
|
||||||
process.env[key] = undefined
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const instance = new API()
|
const instance = new API()
|
||||||
|
|
||||||
await instance.initialize()
|
await instance.initialize()
|
||||||
@ -94,6 +88,7 @@ async function main() {
|
|||||||
if (typeof instance.server.close === "function") {
|
if (typeof instance.server.close === "function") {
|
||||||
instance.server.close()
|
instance.server.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -102,6 +97,7 @@ async function main() {
|
|||||||
if (typeof instance.server.close === "function") {
|
if (typeof instance.server.close === "function") {
|
||||||
instance.server.close()
|
instance.server.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import { webcrypto as crypto } from "crypto"
|
import { webcrypto as crypto } from "crypto"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { registerBaseAliases } from "linebridge/dist/server"
|
import { registerBaseAliases } from "linebridge/dist/server"
|
||||||
@ -18,6 +17,11 @@ const customAliases = {
|
|||||||
|
|
||||||
if (!global.isProduction) {
|
if (!global.isProduction) {
|
||||||
customAliases["comty.js"] = path.resolve(__dirname, "../../comty.js/src")
|
customAliases["comty.js"] = path.resolve(__dirname, "../../comty.js/src")
|
||||||
|
|
||||||
|
customAliases["@shared-classes"] = path.resolve(__dirname, "shared-classes")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.env.USE_LINKED_SHARED) {
|
||||||
customAliases["@shared-classes"] = path.resolve(__dirname, "shared-classes")
|
customAliases["@shared-classes"] = path.resolve(__dirname, "shared-classes")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +73,9 @@ async function main() {
|
|||||||
|
|
||||||
// inject to process.env
|
// inject to process.env
|
||||||
secrets.forEach((secret) => {
|
secrets.forEach((secret) => {
|
||||||
|
if (!(secret.secretName in process.env)) {
|
||||||
process.env[secret.secretName] = secret.secretValue
|
process.env[secret.secretName] = secret.secretValue
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +88,7 @@ async function main() {
|
|||||||
if (typeof instance.server.close === "function") {
|
if (typeof instance.server.close === "function") {
|
||||||
instance.server.close()
|
instance.server.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -90,6 +97,7 @@ async function main() {
|
|||||||
if (typeof instance.server.close === "function") {
|
if (typeof instance.server.close === "function") {
|
||||||
instance.server.close()
|
instance.server.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user