@shellicar/build-azure-local-settings 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Stephen Hellicar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # @shellicar/build-azure-local-settings
2
+
3
+ > Build plugin that loads Azure `local.settings.json` with Key Vault reference resolution for non-Azure-Functions apps.
4
+
5
+ ## Installation & Quick Start
6
+
7
+ ```sh
8
+ npm i --save-dev @shellicar/build-azure-local-settings
9
+ ```
10
+
11
+ ```sh
12
+ pnpm add -D @shellicar/build-azure-local-settings
13
+ ```
14
+
15
+ ```ts
16
+ // tsup.config.ts
17
+ import plugin from '@shellicar/build-azure-local-settings/esbuild';
18
+ import { defineConfig } from 'tsup';
19
+
20
+ export default defineConfig({
21
+ esbuildPlugins: [
22
+ plugin({
23
+ mainModule: './src/main.ts',
24
+ }),
25
+ ],
26
+ });
27
+ ```
28
+
29
+ ```ts
30
+ // build.ts (esbuild)
31
+ import plugin from '@shellicar/build-azure-local-settings/esbuild';
32
+
33
+ await build({
34
+ bundle: true,
35
+ plugins: [
36
+ plugin({
37
+ mainModule: './src/main.ts',
38
+ }),
39
+ ],
40
+ });
41
+ ```
42
+
43
+ ## Documentation
44
+
45
+ For full documentation, visit [the GitHub repository](https://github.com/shellicar/build-azure-local-settings).
@@ -0,0 +1 @@
1
+ "use strict";var e=require("./chunk-PK6SKIKE.cjs"),t=require("node:process"),n=require("@azure/identity"),s=require("@azure/keyvault-secrets"),r=require("node:path"),i=require("node:fs"),a=class t{static{e.__name(this,"KeyVaultIdentifier")}static SecretsCollection="secrets";static KeysCollection="keys";static CertificatesCollection="certificates";id;vaultUri;name;collection;version;constructor(){this.id=new URL("http://localhost"),this.vaultUri=new URL("http://localhost"),this.name="",this.collection="",this.version=null}static parse(e){if(null==e)throw new Error("id cannot be null");const n=t.tryParse(e);if(!n.success)throw new Error(`Invalid ObjectIdentifier: ${e}. Bad number of segments: ${e.pathname.split("/").length}`);return n.identifier}static parseWithCollection(e,n){const s=t.parse(e);if(s.collection.toLowerCase()!==n.toLowerCase())throw new Error(`Invalid ObjectIdentifier: ${e}. segment [1] should be '${n}/', found '${s.collection}'`);return s}static tryParse(e){if(null===e)return{success:!1};const n=e.pathname.split("/");if(3!==n.length&&4!==n.length)return{success:!1};const s=new t;return s.id=e,s.vaultUri=new URL(`${e.protocol}//${e.host}`),s.collection=n[1].replace(/\/$/,""),s.name=n[2].replace(/\/$/,""),s.version=4===n.length?n[3].replace(/\/$/,""):null,{success:!0,identifier:s}}},c=class{static{e.__name(this,"KeyVaultSecretIdentifier")}sourceId;vaultUri;name;version;constructor(e){if(null==e)throw new Error("id cannot be null");const t=a.tryParse(e);if(!t.success||!t.identifier)throw new Error(`${e} is not a valid secret ID`);this.sourceId=e,this.vaultUri=t.identifier.vaultUri,this.name=t.identifier.name,this.version=t.identifier.version}},o=class t{static{e.__name(this,"KeyVaultReferencesManager")}static VaultUriSuffix="vault.azure.net";static _basicKeyVaultReferenceRegex=/^@Microsoft\.KeyVault\((?<ReferenceString>.*)\)$/;_clients=new Map;_credential=new n.DefaultAzureCredential;async resolveKeyVaultReferences(e){const t=Object.keys(e);for(const n of t)try{const t=await this.getSecretValue(n,e[n]);null!=t&&(e[n]=t)}catch{}}async getSecretValue(e,t){const n=this.parseSecret(e,t);if(null!=n){const e=this.getSecretClient(n.uri);return(await e.getSecret(n.name,n.version?{version:n.version}:void 0)).value}return null}parseSecret(e,n){if(null==n)return null;const s=t._basicKeyVaultReferenceRegex.exec(n);if(s?.groups){const t=s.groups.ReferenceString;let n=null;try{null!=t&&(n=this.parseVaultReference(t))}catch{}return null==n&&console.warn(`Unable to parse the Key Vault reference for setting: ${e}`),n}return null}parseVaultReference(e){const n=this.getValueFromVaultReference("SecretUri",e);if(n&&n.length>0){const e=new URL(n),s=new c(e);return new t.ParseSecretResult(s.vaultUri,s.name,s.version)}const s=this.getValueFromVaultReference("VaultName",e),r=this.getValueFromVaultReference("SecretName",e),i=this.getValueFromVaultReference("SecretVersion",e);return s&&s.length>0&&r&&r.length>0?new t.ParseSecretResult(new URL(`https://${s}.${t.VaultUriSuffix}`),r,i):null}getValueFromVaultReference(e,t){const n=new RegExp(e+"=(?<Value>[^;]+)(;|$)").exec(t);return n?.groups?n.groups.Value??null:null}getSecretClient(e){const t=e.toString();let n=this._clients.get(t);return n||(n=new s.SecretClient(t,this._credential),this._clients.set(t,n)),n}};(t=>{class n{static{e.__name(this,"ParseSecretResult")}uri;name;version;constructor(e,t,n){this.uri=e,this.name=t,this.version=n}}t.ParseSecretResult=n})(o||(o={}));var l=class{constructor(e){this.filePath=e,this.values={},this.connectionStrings={},this.isEncrypted=!0;try{const e=i.readFileSync(this.filePath,"utf8"),t=JSON.parse(e);this.isEncrypted=t.IsEncrypted??!0,this.values=t.Values??{},this.connectionStrings=t.ConnectionStrings??{},this.host=t.Host??{}}catch(e){console.warn(`Failed to read app settings file at '${this.filePath}'. Ensure it is a valid JSON file.`,e),this.values={},this.connectionStrings={},this.isEncrypted=!0}}static{e.__name(this,"AppSettingsFile")}isEncrypted;values;connectionStrings;host;getValues(){if(this.isEncrypted)throw new Error("Encrypted settings are not supported in this TypeScript port.");return{...this.values}}getConnectionStrings(){return[]}},u=class t{static{e.__name(this,"SecretsManager")}static _lazySettings=null;static get Settings(){return t._lazySettings||(t._lazySettings=new l(t.AppSettingsFilePath)),t._lazySettings}static get AppSettingsFilePath(){const e="local.settings.json",t=process.cwd(),n=r.join(t,e);return console.log(`'${e}' found in root directory (${t}).`),n}static get AppSettingsFileName(){return"local.settings.json"}getSecrets(e=!1){return e?new l(t.AppSettingsFilePath).getValues():t.Settings.getValues()}getConnectionStrings(){return t.Settings.getConnectionStrings()}},h=class{static{e.__name(this,"StartHostAction")}_secretsManager;_keyVaultReferencesManager;constructor(){this._secretsManager=new u,this._keyVaultReferencesManager=new o}async buildWebHost(){const e=await this.getConfigurationSettings("",new URL("http://localhost:7071"));await this._keyVaultReferencesManager.resolveKeyVaultReferences(e),this.updateEnvironmentVariables(e)}async getConfigurationSettings(e,n){const s=this._secretsManager.getSecrets();s.WebsiteHostname=n.host;const r=this._secretsManager.getConnectionStrings();for(const e of r)s[`ConnectionStrings:${e.name}`]=e.value;s.AzureWebJobsScriptRoot=e;for(const[e,n]of Object.entries(t.env));if(s.AZURE_FUNCTIONS_ENVIRONMENT){const e=s.AZURE_FUNCTIONS_ENVIRONMENT;console.warn(`AZURE_FUNCTIONS_ENVIRONMENT already exists with value '${e}', overriding to 'Development'.`)}return s.AZURE_FUNCTIONS_ENVIRONMENT="Development",s}updateEnvironmentVariables(e){for(const[n,s]of Object.entries(e))n?void 0!==t.env[n]?console.warn(`Skipping '${n}' from local settings as it's already defined in current environment variables.`):s?t.env[n]=s:""===s?t.env[n]="":console.warn(`Skipping '${n}' because value is null`):console.warn("Skipping local setting with empty key.")}};exports.StartHostAction=h;//# sourceMappingURL=StartHostAction-XMDH7T6E.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/local-settings/KeyVaultIdentifier.ts","../../src/local-settings/KeyVaultSecretIdentifier.ts","../../src/local-settings/KeyVaultReferencesManager.ts","../../src/local-settings/AppSettingsFile.ts","../../src/local-settings/SecretsManager.ts","../../src/local-settings/StartHostAction.ts"],"names":["__name","DefaultAzureCredential","SecretClient","KeyVaultReferencesManager","readFileSync","join","env"],"mappings":";AASO,IAAM,kBAAA,GAAN,MAAM,mBAAA,CAAmB;AAAA,EAThC;AASgC,IAAAA,wBAAA,CAAA,IAAA,EAAA,oBAAA,CAAA;AAAA;AAAA,EAC9B,OAAuB,iBAAA,GAAoB,SAAA;AAAA,EAC3C,OAAuB,cAAA,GAAiB,MAAA;AAAA,EACxC,OAAuB,sBAAA,GAAyB,cAAA;AAAA,EAEzC,EAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EAEP,WAAA,GAAc;AAEZ,IAAA,IAAA,CAAK,EAAA,GAAK,IAAI,GAAA,CAAI,kBAAkB,CAAA;AACpC,IAAA,IAAA,CAAK,QAAA,GAAW,IAAI,GAAA,CAAI,kBAAkB,CAAA;AAC1C,IAAA,IAAA,CAAK,IAAA,GAAO,EAAA;AACZ,IAAA,IAAA,CAAK,UAAA,GAAa,EAAA;AAClB,IAAA,IAAA,CAAK,OAAA,GAAU,IAAA;AAAA,EACjB;AAAA,EAEA,OAAc,MAAM,EAAA,EAA6B;AAC/C,IAAA,IAAI,EAAA,KAAO,IAAA,IAAQ,EAAA,KAAO,MAAA,EAAW;AACnC,MAAA,MAAM,IAAI,MAAM,mBAAmB,CAAA;AAAA,IACrC;AAEA,IAAA,MAAM,MAAA,GAAS,mBAAA,CAAmB,QAAA,CAAS,EAAE,CAAA;AAC7C,IAAA,IA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CAAA,MAAA,IAAW,UAAU,EAAA,EAAI;AACvB,QAAAA,gBAAA,CAAI,GAAG,CAAA,GAAI,EAAA;AAAA,MACb,CAAA,MAAO;AACL,QAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,UAAA,EAAa,GAAG,CAAA,uBAAA,CAAyB,CAAA;AAAA,MACxD;AAAA,IACF;AAAA,EACF;AACF","file":"StartHostAction-XMDH7T6E.cjs","sourcesContent":["/**\n * Port of KeyVaultIdentifier from Azure SDK for .NET\n * @see https://github.com/Azure/azure-sdk-for-net/blob/3dad5181b332bf12d5298810f73347ee1bc9980b/sdk/keyvault/Azure.Security.KeyVault.Shared/src/KeyVaultIdentifier.cs\n */\n\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\n// Ported from sdk/keyvault/Azure.Security.KeyVault.Shared/src/KeyVaultIdentifier.cs\nexport class KeyVaultIdentifier {\n public static readonly SecretsCollection = 'secrets';\n public static readonly KeysCollection = 'keys';\n public static readonly CertificatesCollection = 'certificates';\n\n public id: URL;\n public vaultUri: URL;\n public name: string;\n public collection: string;\n public version: string | null;\n\n constructor() {\n // Initialize with defaults - will be set by static methods\n this.id = new URL('http://localhost');\n this.vaultUri = new URL('http://localhost');\n this.name = '';\n this.collection = '';\n this.version = null;\n }\n\n public static parse(id: URL): KeyVaultIdentifier {\n if (id === null || id === undefined) {\n throw new Error('id cannot be null');\n }\n\n const result = KeyVaultIdentifier.tryParse(id);\n if (!result.success) {\n throw new Error(`Invalid ObjectIdentifier: ${id}. Bad number of segments: ${id.pathname.split('/').length}`);\n }\n // biome-ignore lint/style/noNonNullAssertion: tryParse sets identifier when success is true, guarded by the throw above\n return result.identifier!;\n }\n\n public static parseWithCollection(id: URL, collection: string): KeyVaultIdentifier {\n const identifier = KeyVaultIdentifier.parse(id);\n if (identifier.collection.toLowerCase() !== collection.toLowerCase()) {\n throw new Error(`Invalid ObjectIdentifier: ${id}. segment [1] should be '${collection}/', found '${identifier.collection}'`);\n }\n return identifier;\n }\n\n public static tryParse(id: URL | null): { success: boolean; identifier?: KeyVaultIdentifier } {\n if (id === null) {\n return { success: false };\n }\n\n // We expect an identifier with either 3 or 4 segments: host + collection + name [+ version]\n const segments = id.pathname.split('/');\n if (segments.length !== 3 && segments.length !== 4) {\n return { success: false };\n }\n\n const identifier = new KeyVaultIdentifier();\n identifier.id = id;\n identifier.vaultUri = new URL(`${id.protocol}//${id.host}`);\n // biome-ignore lint/style/noNonNullAssertion: length check above guarantees segments[1..3] exist\n identifier.collection = segments[1]!.replace(/\\/$/, ''); // Trim '/'\n // biome-ignore lint/style/noNonNullAssertion: length check above guarantees segments[1..3] exist\n identifier.name = segments[2]!.replace(/\\/$/, ''); // Trim '/'\n // biome-ignore lint/style/noNonNullAssertion: length check above guarantees segments[3] exists when length is 4\n identifier.version = segments.length === 4 ? segments[3]!.replace(/\\/$/, '') : null; // TrimEnd '/'\n\n return { success: true, identifier };\n }\n}\n","/**\n * Port of KeyVaultSecretIdentifier from Azure SDK for .NET\n * @see https://github.com/Azure/azure-sdk-for-net/blob/3dad5181b332bf12d5298810f73347ee1bc9980b/sdk/keyvault/Azure.Security.KeyVault.Secrets/src/KeyVaultSecretIdentifier.cs\n */\n\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nimport { KeyVaultIdentifier } from './KeyVaultIdentifier';\n\n/**\n * Information about a KeyVault Secret parsed from a URL.\n * You can use this information when calling methods of a SecretClient.\n */\nexport class KeyVaultSecretIdentifier {\n /**\n * Gets the source URL passed to KeyVaultSecretIdentifier constructor.\n */\n public sourceId: URL;\n\n /**\n * Gets the URL of the Key Vault.\n */\n public vaultUri: URL;\n\n /**\n * Gets the name of the secret.\n */\n public name: string;\n\n /**\n * Gets the optional version of the secret.\n */\n public version: string | null;\n\n /**\n * Creates a new instance of the KeyVaultSecretIdentifier class.\n * @param id The URL to a secret or deleted secret.\n * @throws Error if id is not a valid Key Vault secret ID.\n */\n public constructor(id: URL) {\n if (id === null || id === undefined) {\n throw new Error('id cannot be null');\n }\n\n const result = KeyVaultIdentifier.tryParse(id);\n if (result.success && result.identifier) {\n this.sourceId = id;\n this.vaultUri = result.identifier.vaultUri;\n this.name = result.identifier.name;\n this.version = result.identifier.version;\n } else {\n throw new Error(`${id} is not a valid secret ID`);\n }\n }\n}\n","/**\n * Port of azure-functions-core-tools reading from local.settings.json\n * @see https://github.com/Azure/azure-functions-core-tools/blob/b367a5155d7bf299c4719dc37051082ae8ddebaf/src/Cli/func/Common/KeyVaultReferencesManager.cs\n */\n\n// Copyright (c) .NET Foundation. All rights reserved.\n// Licensed under the MIT License. See LICENSE in the project root for license information.\n\nimport { DefaultAzureCredential, type TokenCredential } from '@azure/identity';\nimport { SecretClient } from '@azure/keyvault-secrets';\nimport { KeyVaultSecretIdentifier } from './KeyVaultSecretIdentifier';\n\nexport class KeyVaultReferencesManager {\n private static readonly VaultUriSuffix = 'vault.azure.net';\n private static readonly _basicKeyVaultReferenceRegex = /^@Microsoft\\.KeyVault\\((?<ReferenceString>.*)\\)$/;\n\n private readonly _clients = new Map<string, SecretClient>();\n private readonly _credential: TokenCredential = new DefaultAzureCredential(); // CodeQL [SM05137] This is never deployed to production, only used in CLI context in a local dev environment.\n\n public async resolveKeyVaultReferences(settings: { [key: string]: string | undefined }): Promise<void> {\n const keys = Object.keys(settings);\n\n for (const key of keys) {\n try {\n const keyVaultValue = await this.getSecretValue(key, settings[key]);\n if (keyVaultValue != null) {\n settings[key] = keyVaultValue;\n }\n } catch {}\n }\n }\n\n private async getSecretValue(key: string, value: string | undefined): Promise<string | null> {\n const result = this.parseSecret(key, value);\n\n if (result != null) {\n const client = this.getSecretClient(result.uri);\n const secret = await client.getSecret(result.name, result.version ? { version: result.version } : undefined);\n // biome-ignore lint/style/noNonNullAssertion: Key Vault SDK types value as optional but a successfully retrieved secret always has a value in local dev context\n return secret.value!;\n }\n\n return null;\n }\n\n public parseSecret(key: string, value: string | undefined): KeyVaultReferencesManager.ParseSecretResult | null {\n // If the value is null, then we return nothing, as the subsequent call to\n // UpdateEnvironmentVariables(settings) will log to the user that the setting\n // is skipped. We check here, because Regex.Match throws when supplied with a\n // null value.\n if (value == null) {\n return null;\n }\n\n // Determine if the secret value is attempting to use a key vault reference\n const keyVaultReferenceMatch = KeyVaultReferencesManager._basicKeyVaultReferenceRegex.exec(value);\n if (keyVaultReferenceMatch?.groups) {\n const referenceString = keyVaultReferenceMatch.groups['ReferenceString'];\n let result: KeyVaultReferencesManager.ParseSecretResult | null = null;\n try {\n if (referenceString != null) {\n result = this.parseVaultReference(referenceString);\n }\n } catch {\n // ignore and show warning below\n }\n\n // If we detect that a key vault reference was attempted, but did not match any of\n // the supported formats, we write a warning to the console.\n if (result == null) {\n console.warn(`Unable to parse the Key Vault reference for setting: ${key}`);\n }\n\n return result;\n }\n\n return null;\n }\n\n public parseVaultReference(vaultReference: string): KeyVaultReferencesManager.ParseSecretResult | null {\n const secretUriString = this.getValueFromVaultReference('SecretUri', vaultReference);\n if (secretUriString && secretUriString.length > 0) {\n const secretUri = new URL(secretUriString);\n const secretIdentifier = new KeyVaultSecretIdentifier(secretUri);\n return new KeyVaultReferencesManager.ParseSecretResult(secretIdentifier.vaultUri, secretIdentifier.name, secretIdentifier.version);\n }\n\n const vaultName = this.getValueFromVaultReference('VaultName', vaultReference);\n const secretName = this.getValueFromVaultReference('SecretName', vaultReference);\n const version = this.getValueFromVaultReference('SecretVersion', vaultReference);\n if (vaultName && vaultName.length > 0 && secretName && secretName.length > 0) {\n return new KeyVaultReferencesManager.ParseSecretResult(new URL(`https://${vaultName}.${KeyVaultReferencesManager.VaultUriSuffix}`), secretName, version);\n }\n\n return null;\n }\n\n public getValueFromVaultReference(key: string, vaultReference: string): string | null {\n const regex = new RegExp(key + '=(?<Value>[^;]+)(;|$)');\n const match = regex.exec(vaultReference);\n if (match?.groups) {\n return match.groups['Value'] ?? null;\n }\n\n return null;\n }\n\n private getSecretClient(vaultUri: URL): SecretClient {\n const uriString = vaultUri.toString();\n let client = this._clients.get(uriString);\n if (!client) {\n client = new SecretClient(uriString, this._credential);\n this._clients.set(uriString, client);\n }\n return client;\n }\n}\n\nexport namespace KeyVaultReferencesManager {\n export class ParseSecretResult {\n public uri: URL;\n public name: string;\n public version: string | null;\n\n constructor(uri: URL, name: string, version: string | null) {\n this.uri = uri;\n this.name = name;\n this.version = version;\n }\n }\n}\n","/**\n * Port of AppSettingsFile from Azure Functions Core Tools\n * @see https://github.com/Azure/azure-functions-core-tools/blob/b367a5155d7bf299c4719dc37051082ae8ddebaf/src/Cli/func/Common/AppSettingsFile.cs\n */\n\nimport { readFileSync } from 'node:fs';\n\ninterface LocalSettingsJson {\n IsEncrypted?: boolean;\n Values?: Record<string, string>;\n ConnectionStrings?: Record<string, any>;\n Host?: any;\n}\n\nexport class AppSettingsFile {\n public isEncrypted: boolean;\n public values: Record<string, string>;\n public connectionStrings: Record<string, any>;\n public host: any;\n\n constructor(private filePath: string) {\n this.values = {};\n this.connectionStrings = {};\n this.isEncrypted = true;\n\n try {\n const content = readFileSync(this.filePath, 'utf8');\n const appSettings: LocalSettingsJson = JSON.parse(content);\n\n this.isEncrypted = appSettings.IsEncrypted ?? true;\n this.values = appSettings.Values ?? {};\n this.connectionStrings = appSettings.ConnectionStrings ?? {};\n this.host = appSettings.Host ?? {};\n } catch (ex) {\n console.warn(`Failed to read app settings file at '${this.filePath}'. Ensure it is a valid JSON file.`, ex);\n this.values = {};\n this.connectionStrings = {};\n this.isEncrypted = true;\n }\n }\n\n public getValues(): Record<string, string> {\n if (this.isEncrypted) {\n throw new Error('Encrypted settings are not supported in this TypeScript port.');\n }\n return { ...this.values };\n }\n\n public getConnectionStrings(): any[] {\n return [];\n }\n}\n","/**\n * Port of SecretsManager from Azure Functions Core Tools\n * @see https://github.com/Azure/azure-functions-core-tools/blob/b367a5155d7bf299c4719dc37051082ae8ddebaf/src/Cli/func/Common/SecretsManager.cs\n */\n\nimport { join } from 'node:path';\nimport { AppSettingsFile } from './AppSettingsFile';\n\nexport class SecretsManager {\n private static _lazySettings: AppSettingsFile | null = null;\n\n private static get Settings(): AppSettingsFile {\n if (!SecretsManager._lazySettings) {\n SecretsManager._lazySettings = new AppSettingsFile(SecretsManager.AppSettingsFilePath);\n }\n return SecretsManager._lazySettings;\n }\n\n public static get AppSettingsFilePath(): string {\n const secretsFile = 'local.settings.json';\n const rootPath = process.cwd();\n const secretsFilePath = join(rootPath, secretsFile);\n\n console.log(`'${secretsFile}' found in root directory (${rootPath}).`);\n return secretsFilePath;\n }\n\n public static get AppSettingsFileName(): string {\n return 'local.settings.json';\n }\n\n public getSecrets(refreshSecrets = false): Record<string, string> {\n if (refreshSecrets) {\n return new AppSettingsFile(SecretsManager.AppSettingsFilePath).getValues();\n }\n\n return SecretsManager.Settings.getValues();\n }\n\n public getConnectionStrings(): any[] {\n return SecretsManager.Settings.getConnectionStrings();\n }\n}\n","/**\n * Port of StartHostAction from Azure Functions Core Tools (partial)\n * @see https://github.com/Azure/azure-functions-core-tools/blob/b367a5155d7bf299c4719dc37051082ae8ddebaf/src/Cli/func/Actions/HostActions/StartHostAction.cs\n */\n\nimport { env } from 'node:process';\nimport { KeyVaultReferencesManager } from './KeyVaultReferencesManager';\nimport { SecretsManager } from './SecretsManager';\n\nexport class StartHostAction {\n private readonly _secretsManager: SecretsManager;\n private readonly _keyVaultReferencesManager: KeyVaultReferencesManager;\n\n constructor() {\n this._secretsManager = new SecretsManager();\n this._keyVaultReferencesManager = new KeyVaultReferencesManager();\n }\n\n public async buildWebHost(): Promise<void> {\n const settings = await this.getConfigurationSettings('', new URL('http://localhost:7071'));\n await this._keyVaultReferencesManager.resolveKeyVaultReferences(settings);\n this.updateEnvironmentVariables(settings);\n }\n\n private async getConfigurationSettings(scriptPath: string, uri: URL): Promise<Record<string, string>> {\n const settings = this._secretsManager.getSecrets();\n settings['WebsiteHostname'] = uri.host;\n\n const connectionStrings = this._secretsManager.getConnectionStrings();\n for (const connectionString of connectionStrings) {\n settings[`ConnectionStrings:${connectionString.name}`] = connectionString.value;\n }\n settings['AzureWebJobsScriptRoot'] = scriptPath;\n\n const environment: Record<string, string> = {};\n for (const [key, value] of Object.entries(env)) {\n if (typeof value === 'string') {\n environment[key] = value;\n }\n }\n\n if (settings['AZURE_FUNCTIONS_ENVIRONMENT']) {\n const oldValue = settings['AZURE_FUNCTIONS_ENVIRONMENT'];\n console.warn(`AZURE_FUNCTIONS_ENVIRONMENT already exists with value '${oldValue}', overriding to 'Development'.`);\n }\n\n settings['AZURE_FUNCTIONS_ENVIRONMENT'] = 'Development';\n\n return settings;\n }\n\n private updateEnvironmentVariables(secrets: Record<string, string>): void {\n for (const [key, value] of Object.entries(secrets)) {\n if (!key) {\n console.warn('Skipping local setting with empty key.');\n } else if (env[key] !== undefined) {\n console.warn(`Skipping '${key}' from local settings as it's already defined in current environment variables.`);\n } else if (value) {\n env[key] = value;\n } else if (value === '') {\n env[key] = '';\n } else {\n console.warn(`Skipping '${key}' because value is null`);\n }\n }\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ "use strict";var e=Object.defineProperty;exports.__name=(r,a)=>e(r,"name",{value:a,configurable:!0});//# sourceMappingURL=chunk-PK6SKIKE.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-PK6SKIKE.cjs"}
@@ -0,0 +1 @@
1
+ "use strict";var e=require("./chunk-PK6SKIKE.cjs");require("regexp.escape/auto");var t=(e=>(e.EsbuildEntryInjection="ESBUILD_ENTRY_INJECTION",e.CjsShimAutoInclude="CJS_SHIM_AUTO_INCLUDE",e))(t||{}),r=class extends Error{static{e.__name(this,"BundlerNotConfiguredError")}constructor(){super("build-azure-local-settings requires esbuild bundle option to be enabled. Without bundling, imports in the generated entry point are not resolved."),this.name="BundlerNotConfiguredError"}},o=class extends Error{static{e.__name(this,"NodePlatformRequiredError")}constructor(e){super(`loadLocalSettings requires platform: 'node', but platform is '${e??"undefined"}'. Either set platform: 'node' or disable loadLocalSettings.`),this.name="NodePlatformRequiredError"}},n="azure-local-settings-ns",s=e.__name((e,t)=>{const r=["/**"," * @generated by @shellicar/build-azure-local-settings",` * @generated-at ${(new Date).toISOString()}`," * WARNING: This code is auto-generated. Do not edit manually."," */",""];"esm"===t&&e.features.CJS_SHIM_AUTO_INCLUDE&&r.push("import '@shellicar/build-azure-local-settings/cjs-shim';");for(const t of e.sideEffectImports)r.push(`import '${t}';`);let o;"default"===e.mainExport?(o="main",r.push(`import ${o} from '${e.mainModule}';`)):(o=e.mainExport,r.push(`import { ${o} } from '${e.mainModule}';`)),e.loadLocalSettings&&r.push("import { loadLocalSettings } from '@shellicar/build-azure-local-settings/runtime';"),r.push("");const n=[];if(e.loadLocalSettings&&n.push("await loadLocalSettings();"),n.push(`await ${o}();`),"cjs"===t){r.push("(async () => {");for(const e of n)r.push(` ${e}`);r.push("})();")}else for(const e of n)r.push(e);return r.join("\n")},"generateVirtualModule"),a=e.__name(e=>`virtual:azure-local-settings/${e}`,"getVirtualModuleId"),i=e.__name((e,t,r)=>{const o=e.entryPoints;Array.isArray(o)?e.entryPoints=[...o,r]:e.entryPoints="object"==typeof o&&null!==o?{...o,[t]:r}:{[t]:r}},"injectEntryPoint"),l=class extends Error{static{e.__name(this,"UnsupportedFormatError")}constructor(e){super(`Unsupported format: ${e}. Only cjs or esm are supported.`),this.name="UnsupportedFormatError"}},u=class extends Error{static{e.__name(this,"UnsupportedPlatformError")}constructor(e){super(`Unsupported platform: ${e??"undefined"}. Only node or neutral are supported when format is not set.`),this.name="UnsupportedPlatformError"}},p=e.__name(e=>{const t=e.define?.TSUP_FORMAT,r=t?JSON.parse(t):e.format;if(r){if("cjs"===r||"esm"===r)return r;throw new l(r)}if("node"===e.platform)return"cjs";if("neutral"===e.platform)return"esm";throw new u(e.platform)},"resolveFormat"),d=e.__name(e=>{const t=a(e.entryName);return{name:"azure-local-settings",setup(a){if(!a.initialOptions.bundle)throw new r;if(e.loadLocalSettings&&"node"!==a.initialOptions.platform)throw new o(a.initialOptions.platform);const l=p(a.initialOptions);e.features.ESBUILD_ENTRY_INJECTION&&i(a.initialOptions,e.entryName,t);const u=new RegExp(`^${RegExp.escape(t)}$`);a.onResolve({filter:u},e=>({path:e.path,namespace:n}));const d=a.initialOptions.absWorkingDir??process.cwd();a.onLoad({filter:/.*/,namespace:n},()=>({contents:s(e,l),loader:"ts",resolveDir:d}))}}},"createPlugin"),c={entryName:"main",mainExport:"default",sideEffectImports:[],loadLocalSettings:!0,debug:!1,features:{ESBUILD_ENTRY_INJECTION:!0,CJS_SHIM_AUTO_INCLUDE:!0}},m=e.__name(e=>({...c,...e,features:{...c.features,...e.features}}),"resolveOptions"),f=e.__name(e=>{if(!e?.mainModule)throw new Error("build-azure-local-settings: mainModule option is required");const t=m(e);return d(t)},"plugin");exports.Feature=t,exports.esbuild_default=f;//# sourceMappingURL=chunk-X2PGEG2F.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/enums.ts","../../src/errors/BundlerNotConfiguredError.ts","../../src/errors/NodePlatformRequiredError.ts","../../src/core/consts.ts","../../src/core/generateVirtualModule.ts","../../src/core/getVirtualModuleId.ts","../../src/core/injectEntryPoint.ts","../../src/errors/UnsupportedFormatError.ts","../../src/errors/UnsupportedPlatformError.ts","../../src/core/resolveFormat.ts","../../src/core/createPlugin.ts","../../src/core/defaultOptions.ts","../../src/core/resolveOptions.ts","../../src/core/plugin.ts","../../src/esbuild.ts"],"names":["Feature","__name"],"mappings":";AAEO,IAAK,OAAA,qBAAAA,QAAAA,KAAL;AAML,EAAAA,SAAA,uBAAA,CAAA,GAAwB,yBAAA;AAOxB,EAAAA,SAAA,oBAAA,CAAA,GAAqB,uBAAA;AAbX,EAAA,OAAAA,QAAAA;AAAA,CAAA,EAAA,OAAA,IAAA,EAAA;;;ACEL,IAAM,yBAAA,GAAN,cAAwC,KAAA,CAAM;AAAA,EAJrD;AAIqD,IAAAC,wBAAA,CAAA,IAAA,EAAA,2BAAA,CAAA;AAA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6CAAU,YAAA,KAAkC;AACvD,EAAA,IAAI,CAAC,cAAc,UAAA,EAAY;AAC7B,IAAA,MAAM,IAAI,MAAM,2DAA2D,CAAA;AAAA,EAC7E;AAEA,EAAA,MAAM,OAAA,GAAU,eAAe,YAAY,CAAA;AAC3C,EAAA,OAAO,aAAa,OAAO,CAAA;AAC7B,CAAA,EAPsB,QAAA,CAAA;;;ACHtB,IAAO,eAAA,GAAQ","file":"chunk-X2PGEG2F.cjs","sourcesContent":["import type { Options } from './types';\n\nexport enum Feature {\n /**\n * Enables automatic entry point injection for esbuild.\n * When enabled, `virtual:azure-local-settings/main` is automatically added to esbuild's entryPoints.\n * Note: `main` is the default value of {@link Options.entryName}.\n */\n EsbuildEntryInjection = 'ESBUILD_ENTRY_INJECTION',\n\n /**\n * Enables automatic cjs-shim import for ESM builds.\n * The cjs-shim provides `require`, `__filename`, and `__dirname` globals\n * which are needed when bundling CJS dependencies in ESM output.\n */\n CjsShimAutoInclude = 'CJS_SHIM_AUTO_INCLUDE',\n}\n","/**\n * Error thrown when esbuild's bundle option is not enabled.\n * Without bundling, imports in the virtual entry point are not resolved.\n */\nexport class BundlerNotConfiguredError extends Error {\n public constructor() {\n super('build-azure-local-settings requires esbuild bundle option to be enabled. ' + 'Without bundling, imports in the generated entry point are not resolved.');\n this.name = 'BundlerNotConfiguredError';\n }\n}\n","export class NodePlatformRequiredError extends Error {\n constructor(platform: string | undefined) {\n super(`loadLocalSettings requires platform: 'node', but platform is '${platform ?? 'undefined'}'. Either set platform: 'node' or disable loadLocalSettings.`);\n this.name = 'NodePlatformRequiredError';\n }\n}\n","export const pluginName = 'azure-local-settings';\nexport const pluginNamespace = 'azure-local-settings-ns';\n","import { Feature } from '../enums';\nimport type { SupportedFormat } from './resolveFormat';\nimport type { ResolvedOptions } from './types';\n\nexport const generateVirtualModule = (options: ResolvedOptions, format: SupportedFormat): string => {\n const lines: string[] = ['/**', ' * @generated by @shellicar/build-azure-local-settings', ` * @generated-at ${new Date().toISOString()}`, ' * WARNING: This code is auto-generated. Do not edit manually.', ' */', ''];\n\n if (format === 'esm' && options.features[Feature.CjsShimAutoInclude]) {\n lines.push(\"import '@shellicar/build-azure-local-settings/cjs-shim';\");\n }\n\n for (const importPath of options.sideEffectImports) {\n lines.push(`import '${importPath}';`);\n }\n\n let exportName: string;\n if (options.mainExport === 'default') {\n exportName = 'main';\n lines.push(`import ${exportName} from '${options.mainModule}';`);\n } else {\n exportName = options.mainExport;\n lines.push(`import { ${exportName} } from '${options.mainModule}';`);\n }\n\n if (options.loadLocalSettings) {\n lines.push(\"import { loadLocalSettings } from '@shellicar/build-azure-local-settings/runtime';\");\n }\n\n lines.push('');\n\n const asyncLines: string[] = [];\n if (options.loadLocalSettings) {\n asyncLines.push('await loadLocalSettings();');\n }\n asyncLines.push(`await ${exportName}();`);\n\n if (format === 'cjs') {\n lines.push('(async () => {');\n for (const line of asyncLines) {\n lines.push(` ${line}`);\n }\n lines.push('})();');\n } else {\n for (const line of asyncLines) {\n lines.push(line);\n }\n }\n\n return lines.join('\\n');\n};\n","// Use a path-like format so esbuild uses the basename for output\n\nexport const getVirtualModuleId = (entryName: string): string => `virtual:azure-local-settings/${entryName}`;\n","import type { BuildOptions } from 'esbuild';\n\nexport const injectEntryPoint = (initialOptions: BuildOptions, entryName: string, virtualModuleId: string): void => {\n const entryPoints = initialOptions.entryPoints;\n\n if (Array.isArray(entryPoints)) {\n initialOptions.entryPoints = [...entryPoints, virtualModuleId];\n } else if (typeof entryPoints === 'object' && entryPoints !== null) {\n initialOptions.entryPoints = {\n ...entryPoints,\n [entryName]: virtualModuleId,\n };\n } else {\n initialOptions.entryPoints = { [entryName]: virtualModuleId };\n }\n};\n","export class UnsupportedFormatError extends Error {\n constructor(format: string) {\n super(`Unsupported format: ${format}. Only cjs or esm are supported.`);\n this.name = 'UnsupportedFormatError';\n }\n}\n","export class UnsupportedPlatformError extends Error {\n constructor(platform: string | undefined) {\n super(`Unsupported platform: ${platform ?? 'undefined'}. Only node or neutral are supported when format is not set.`);\n this.name = 'UnsupportedPlatformError';\n }\n}\n","import type { BuildOptions } from 'esbuild';\nimport { UnsupportedFormatError } from '../errors/UnsupportedFormatError';\nimport { UnsupportedPlatformError } from '../errors/UnsupportedPlatformError';\n\nexport type SupportedFormat = 'cjs' | 'esm';\n\n/**\n * Resolves the output format from esbuild options.\n *\n * Checks in order:\n * 1. TSUP_FORMAT define (for tsup compatibility - value is JSON like \"\\\"cjs\\\"\")\n * 2. esbuild format option\n * 3. Platform-based defaults (node → cjs, neutral → esm)\n *\n * @see https://esbuild.github.io/api/#format\n * @see https://github.com/egoist/tsup/blob/b906f86102c02f1ef66ebd4a3f7ff50bdc07af65/src/esbuild/index.ts#L204\n * @throws {UnsupportedFormatError} If format is set to something other than cjs or esm\n * @throws {UnsupportedPlatformError} If format is not set and platform is not node or neutral\n */\nexport const resolveFormat = (initialOptions: BuildOptions): SupportedFormat => {\n // Get format from TSUP_FORMAT (JSON string) or esbuild format option\n const tsupFormat = initialOptions.define?.TSUP_FORMAT;\n const format = tsupFormat ? JSON.parse(tsupFormat) : initialOptions.format;\n\n if (format) {\n if (format === 'cjs' || format === 'esm') {\n return format;\n }\n throw new UnsupportedFormatError(format);\n }\n\n // Format not set - use platform defaults\n if (initialOptions.platform === 'node') {\n return 'cjs';\n }\n if (initialOptions.platform === 'neutral') {\n return 'esm';\n }\n\n throw new UnsupportedPlatformError(initialOptions.platform);\n};\n","import 'regexp.escape/auto';\nimport type { Plugin } from 'esbuild';\nimport { Feature } from '../enums';\nimport { BundlerNotConfiguredError } from '../errors/BundlerNotConfiguredError';\nimport { NodePlatformRequiredError } from '../errors/NodePlatformRequiredError';\nimport { pluginName, pluginNamespace } from './consts';\nimport { generateVirtualModule } from './generateVirtualModule';\nimport { getVirtualModuleId } from './getVirtualModuleId';\nimport { injectEntryPoint } from './injectEntryPoint';\nimport { resolveFormat } from './resolveFormat';\nimport type { ResolvedOptions } from './types';\n\nexport const createPlugin = (options: ResolvedOptions): Plugin => {\n const virtualModuleId = getVirtualModuleId(options.entryName);\n\n return {\n name: pluginName,\n setup(build) {\n if (!build.initialOptions.bundle) {\n throw new BundlerNotConfiguredError();\n }\n\n if (options.loadLocalSettings && build.initialOptions.platform !== 'node') {\n throw new NodePlatformRequiredError(build.initialOptions.platform);\n }\n\n const format = resolveFormat(build.initialOptions);\n\n // Add virtual entry point\n if (options.features[Feature.EsbuildEntryInjection]) {\n injectEntryPoint(build.initialOptions, options.entryName, virtualModuleId);\n }\n\n // Resolve virtual module\n const virtualModuleFilter = new RegExp(`^${RegExp.escape(virtualModuleId)}$`);\n build.onResolve({ filter: virtualModuleFilter }, (args) => ({\n path: args.path,\n namespace: pluginNamespace,\n }));\n\n // Load virtual module content\n const resolveDir = build.initialOptions.absWorkingDir ?? process.cwd();\n build.onLoad({ filter: /.*/, namespace: pluginNamespace }, () => ({\n contents: generateVirtualModule(options, format),\n loader: 'ts',\n resolveDir,\n }));\n },\n };\n};\n","import { Feature } from '../enums';\nimport type { Options } from '../types';\n\ntype DefaultOptions = Omit<Required<Options>, 'mainModule' | 'features'> & {\n features: Record<Feature, boolean>;\n};\n\nexport const defaultOptions: DefaultOptions = {\n entryName: 'main',\n mainExport: 'default',\n sideEffectImports: [],\n loadLocalSettings: true,\n debug: false,\n features: {\n [Feature.EsbuildEntryInjection]: true,\n [Feature.CjsShimAutoInclude]: true,\n },\n};\n","import type { Options } from '../types';\nimport { defaultOptions } from './defaultOptions';\nimport type { ResolvedOptions } from './types';\n\nexport const resolveOptions = (inputOptions: Options): ResolvedOptions => {\n const options = {\n ...defaultOptions,\n ...inputOptions,\n features: {\n ...defaultOptions.features,\n ...inputOptions.features,\n },\n } satisfies ResolvedOptions;\n\n return options;\n};\n","import type { Plugin } from 'esbuild';\nimport type { Options } from '../types';\nimport { createPlugin } from './createPlugin';\nimport { resolveOptions } from './resolveOptions';\n\nexport const plugin = (inputOptions: Options): Plugin => {\n if (!inputOptions?.mainModule) {\n throw new Error('build-azure-local-settings: mainModule option is required');\n }\n\n const options = resolveOptions(inputOptions);\n return createPlugin(options);\n};\n","import { plugin } from './core/plugin';\n\nexport default plugin;\n"]}
@@ -0,0 +1 @@
1
+ "use strict";var e=require("./chunk-X2PGEG2F.cjs");require("./chunk-PK6SKIKE.cjs"),module.exports=e.esbuild_default;//# sourceMappingURL=esbuild.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"esbuild.cjs"}
@@ -0,0 +1,6 @@
1
+ import plugin from './index.cjs';
2
+ import 'esbuild';
3
+
4
+
5
+
6
+ export { plugin as default };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./chunk-X2PGEG2F.cjs");require("./chunk-PK6SKIKE.cjs"),Object.defineProperty(exports,"Feature",{enumerable:!0,get:function(){return e.Feature}}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return e.esbuild_default}}),Object.defineProperty(exports,"plugin",{enumerable:!0,get:function(){return e.esbuild_default}});//# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -0,0 +1,61 @@
1
+ import { Plugin } from 'esbuild';
2
+
3
+ declare enum Feature {
4
+ /**
5
+ * Enables automatic entry point injection for esbuild.
6
+ * When enabled, `virtual:azure-local-settings/main` is automatically added to esbuild's entryPoints.
7
+ * Note: `main` is the default value of {@link Options.entryName}.
8
+ */
9
+ EsbuildEntryInjection = "ESBUILD_ENTRY_INJECTION",
10
+ /**
11
+ * Enables automatic cjs-shim import for ESM builds.
12
+ * The cjs-shim provides `require`, `__filename`, and `__dirname` globals
13
+ * which are needed when bundling CJS dependencies in ESM output.
14
+ */
15
+ CjsShimAutoInclude = "CJS_SHIM_AUTO_INCLUDE"
16
+ }
17
+
18
+ interface Options {
19
+ /**
20
+ * The name for the entry point in esbuild's entryPoints
21
+ * @default 'main'
22
+ * @example 'main'
23
+ */
24
+ entryName?: string;
25
+ /**
26
+ * Path to the main module to import and run
27
+ * @example './src/main.ts'
28
+ */
29
+ mainModule: string;
30
+ /**
31
+ * The export to import from mainModule.
32
+ * Use 'default' for default exports, or specify a named export.
33
+ * @default 'default'
34
+ */
35
+ mainExport?: string;
36
+ /**
37
+ * Side-effect imports to include before the main module
38
+ * These are imports that execute code on load (e.g., 'dotenv/config')
39
+ * @example ['dotenv/config', './cjs-shim']
40
+ */
41
+ sideEffectImports?: string[];
42
+ /**
43
+ * Whether to load local.settings.json with Key Vault reference resolution
44
+ * @default true
45
+ */
46
+ loadLocalSettings?: boolean;
47
+ /**
48
+ * Enable debug logging
49
+ * @default false
50
+ */
51
+ debug?: boolean;
52
+ /**
53
+ * Feature flags for bundler-specific functionality
54
+ */
55
+ features?: Features;
56
+ }
57
+ type Features = Partial<Record<Feature, boolean>>;
58
+
59
+ declare const plugin: (inputOptions: Options) => Plugin;
60
+
61
+ export { Feature, type Features, type Options, plugin as default, plugin };
@@ -0,0 +1 @@
1
+ "use strict";var t=require("./chunk-PK6SKIKE.cjs").__name(async()=>{const{StartHostAction:t}=await import("./StartHostAction-XMDH7T6E.cjs"),a=new t;await a.buildWebHost()},"loadLocalSettings");exports.loadLocalSettings=t;//# sourceMappingURL=runtime.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/local-settings/loadLocalSettings.ts"],"names":["__name"],"mappings":";AAAO,IAAM,oCAAoBA,wBAAA,CAAA,YAA2B;AAC1D,EAAA,MAAM,EAAE,eAAA,EAAgB,GAAI,MAAM,OAAO,gCAAmB,CAAA;AAC5D,EAAA,MAAM,IAAA,GAAO,IAAI,eAAA,EAAgB;AACjC,EAAA,MAAM,KAAK,YAAA,EAAa;AAC1B,CAAA,EAJiC,mBAAA","file":"runtime.cjs","sourcesContent":["export const loadLocalSettings = async (): Promise<void> => {\n const { StartHostAction } = await import('./StartHostAction');\n const host = new StartHostAction();\n await host.buildWebHost();\n};\n"]}
@@ -0,0 +1,3 @@
1
+ declare const loadLocalSettings: () => Promise<void>;
2
+
3
+ export { loadLocalSettings };
@@ -0,0 +1 @@
1
+ import{__name as e}from"./chunk-7QVYU63E.js";import{env as t}from"node:process";import{DefaultAzureCredential as n}from"@azure/identity";import{SecretClient as s}from"@azure/keyvault-secrets";import{join as r}from"node:path";import{readFileSync as i}from"node:fs";var a=class t{static{e(this,"KeyVaultIdentifier")}static SecretsCollection="secrets";static KeysCollection="keys";static CertificatesCollection="certificates";id;vaultUri;name;collection;version;constructor(){this.id=new URL("http://localhost"),this.vaultUri=new URL("http://localhost"),this.name="",this.collection="",this.version=null}static parse(e){if(null==e)throw new Error("id cannot be null");const n=t.tryParse(e);if(!n.success)throw new Error(`Invalid ObjectIdentifier: ${e}. Bad number of segments: ${e.pathname.split("/").length}`);return n.identifier}static parseWithCollection(e,n){const s=t.parse(e);if(s.collection.toLowerCase()!==n.toLowerCase())throw new Error(`Invalid ObjectIdentifier: ${e}. segment [1] should be '${n}/', found '${s.collection}'`);return s}static tryParse(e){if(null===e)return{success:!1};const n=e.pathname.split("/");if(3!==n.length&&4!==n.length)return{success:!1};const s=new t;return s.id=e,s.vaultUri=new URL(`${e.protocol}//${e.host}`),s.collection=n[1].replace(/\/$/,""),s.name=n[2].replace(/\/$/,""),s.version=4===n.length?n[3].replace(/\/$/,""):null,{success:!0,identifier:s}}},o=class{static{e(this,"KeyVaultSecretIdentifier")}sourceId;vaultUri;name;version;constructor(e){if(null==e)throw new Error("id cannot be null");const t=a.tryParse(e);if(!t.success||!t.identifier)throw new Error(`${e} is not a valid secret ID`);this.sourceId=e,this.vaultUri=t.identifier.vaultUri,this.name=t.identifier.name,this.version=t.identifier.version}},c=class t{static{e(this,"KeyVaultReferencesManager")}static VaultUriSuffix="vault.azure.net";static _basicKeyVaultReferenceRegex=/^@Microsoft\.KeyVault\((?<ReferenceString>.*)\)$/;_clients=new Map;_credential=new n;async resolveKeyVaultReferences(e){const t=Object.keys(e);for(const n of t)try{const t=await this.getSecretValue(n,e[n]);null!=t&&(e[n]=t)}catch{}}async getSecretValue(e,t){const n=this.parseSecret(e,t);if(null!=n){const e=this.getSecretClient(n.uri);return(await e.getSecret(n.name,n.version?{version:n.version}:void 0)).value}return null}parseSecret(e,n){if(null==n)return null;const s=t._basicKeyVaultReferenceRegex.exec(n);if(s?.groups){const t=s.groups.ReferenceString;let n=null;try{null!=t&&(n=this.parseVaultReference(t))}catch{}return null==n&&console.warn(`Unable to parse the Key Vault reference for setting: ${e}`),n}return null}parseVaultReference(e){const n=this.getValueFromVaultReference("SecretUri",e);if(n&&n.length>0){const e=new URL(n),s=new o(e);return new t.ParseSecretResult(s.vaultUri,s.name,s.version)}const s=this.getValueFromVaultReference("VaultName",e),r=this.getValueFromVaultReference("SecretName",e),i=this.getValueFromVaultReference("SecretVersion",e);return s&&s.length>0&&r&&r.length>0?new t.ParseSecretResult(new URL(`https://${s}.${t.VaultUriSuffix}`),r,i):null}getValueFromVaultReference(e,t){const n=new RegExp(e+"=(?<Value>[^;]+)(;|$)").exec(t);return n?.groups?n.groups.Value??null:null}getSecretClient(e){const t=e.toString();let n=this._clients.get(t);return n||(n=new s(t,this._credential),this._clients.set(t,n)),n}};(t=>{class n{static{e(this,"ParseSecretResult")}uri;name;version;constructor(e,t,n){this.uri=e,this.name=t,this.version=n}}t.ParseSecretResult=n})(c||(c={}));var l=class{constructor(e){this.filePath=e,this.values={},this.connectionStrings={},this.isEncrypted=!0;try{const e=i(this.filePath,"utf8"),t=JSON.parse(e);this.isEncrypted=t.IsEncrypted??!0,this.values=t.Values??{},this.connectionStrings=t.ConnectionStrings??{},this.host=t.Host??{}}catch(e){console.warn(`Failed to read app settings file at '${this.filePath}'. Ensure it is a valid JSON file.`,e),this.values={},this.connectionStrings={},this.isEncrypted=!0}}static{e(this,"AppSettingsFile")}isEncrypted;values;connectionStrings;host;getValues(){if(this.isEncrypted)throw new Error("Encrypted settings are not supported in this TypeScript port.");return{...this.values}}getConnectionStrings(){return[]}},u=class t{static{e(this,"SecretsManager")}static _lazySettings=null;static get Settings(){return t._lazySettings||(t._lazySettings=new l(t.AppSettingsFilePath)),t._lazySettings}static get AppSettingsFilePath(){const e="local.settings.json",t=process.cwd(),n=r(t,e);return console.log(`'${e}' found in root directory (${t}).`),n}static get AppSettingsFileName(){return"local.settings.json"}getSecrets(e=!1){return e?new l(t.AppSettingsFilePath).getValues():t.Settings.getValues()}getConnectionStrings(){return t.Settings.getConnectionStrings()}},h=class{static{e(this,"StartHostAction")}_secretsManager;_keyVaultReferencesManager;constructor(){this._secretsManager=new u,this._keyVaultReferencesManager=new c}async buildWebHost(){const e=await this.getConfigurationSettings("",new URL("http://localhost:7071"));await this._keyVaultReferencesManager.resolveKeyVaultReferences(e),this.updateEnvironmentVariables(e)}async getConfigurationSettings(e,n){const s=this._secretsManager.getSecrets();s.WebsiteHostname=n.host;const r=this._secretsManager.getConnectionStrings();for(const e of r)s[`ConnectionStrings:${e.name}`]=e.value;s.AzureWebJobsScriptRoot=e;for(const[e,n]of Object.entries(t));if(s.AZURE_FUNCTIONS_ENVIRONMENT){const e=s.AZURE_FUNCTIONS_ENVIRONMENT;console.warn(`AZURE_FUNCTIONS_ENVIRONMENT already exists with value '${e}', overriding to 'Development'.`)}return s.AZURE_FUNCTIONS_ENVIRONMENT="Development",s}updateEnvironmentVariables(e){for(const[n,s]of Object.entries(e))n?void 0!==t[n]?console.warn(`Skipping '${n}' from local settings as it's already defined in current environment variables.`):s?t[n]=s:""===s?t[n]="":console.warn(`Skipping '${n}' because value is null`):console.warn("Skipping local setting with empty key.")}};export{h as StartHostAction};//# sourceMappingURL=StartHostAction-IGJTX6EF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/local-settings/KeyVaultIdentifier.ts","../../src/local-settings/KeyVaultSecretIdentifier.ts","../../src/local-settings/KeyVaultReferencesManager.ts","../../src/local-settings/AppSettingsFile.ts","../../src/local-settings/SecretsManager.ts","../../src/local-settings/StartHostAction.ts"],"names":["KeyVaultReferencesManager"],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MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,GAAG,CAAA,EAAG;AAG9C,IACF;AAEA,IAAA,IAAI,QAAA,CAAS,6BAA6B,CAAA,EAAG;AAC3C,MAAA,MAAM,QAAA,GAAW,SAAS,6BAA6B,CAAA;AACvD,MAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,uDAAA,EAA0D,QAAQ,CAAA,+BAAA,CAAiC,CAAA;AAAA,IAClH;AAEA,IAAA,QAAA,CAAS,6BAA6B,CAAA,GAAI,aAAA;AAE1C,IAAA,OAAO,QAAA;AAAA,EACT;AAAA,EAEQ,2BAA2B,OAAA,EAAuC;AACxE,IAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,EAAG;AAClD,MAAA,IAAI,CAAC,GAAA,EAAK;AACR,QAAA,OAAA,CAAQ,KAAK,wCAAwC,CAAA;AAAA,MACvD,CAAA,MAAA,IAAW,GAAA,CAAI,GAAG,CAAA,KAAM,MAAA,EAAW;AACjC,QAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,UAAA,EAAa,GAAG,CAAA,+EAAA,CAAiF,CAAA;AAAA,MAChH,WAAW,KAAA,EAAO;AAChB,QAAA,GAAA,CAAI,GAAG,CAAA,GAAI,KAAA;AAAA,MACb,CAAA,MAAA,IAAW,UAAU,EAAA,EAAI;AACvB,QAAA,GAAA,CAAI,GAAG,CAAA,GAAI,EAAA;AAAA,MACb,CAAA,MAAO;AACL,QAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,UAAA,EAAa,GAAG,CAAA,uBAAA,CAAyB,CAAA;AAAA,MACxD;AAAA,IACF;AAAA,EACF;AACF","file":"StartHostAction-IGJTX6EF.js","sourcesContent":["/**\n * Port of KeyVaultIdentifier from Azure SDK for .NET\n * @see https://github.com/Azure/azure-sdk-for-net/blob/3dad5181b332bf12d5298810f73347ee1bc9980b/sdk/keyvault/Azure.Security.KeyVault.Shared/src/KeyVaultIdentifier.cs\n */\n\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\n// Ported from sdk/keyvault/Azure.Security.KeyVault.Shared/src/KeyVaultIdentifier.cs\nexport class KeyVaultIdentifier {\n public static readonly SecretsCollection = 'secrets';\n public static readonly KeysCollection = 'keys';\n public static readonly CertificatesCollection = 'certificates';\n\n public id: URL;\n public vaultUri: URL;\n public name: string;\n public collection: string;\n public version: string | null;\n\n constructor() {\n // Initialize with defaults - will be set by static methods\n this.id = new URL('http://localhost');\n this.vaultUri = new URL('http://localhost');\n this.name = '';\n this.collection = '';\n this.version = null;\n }\n\n public static parse(id: URL): KeyVaultIdentifier {\n if (id === null || id === undefined) {\n throw new Error('id cannot be null');\n }\n\n const result = KeyVaultIdentifier.tryParse(id);\n if (!result.success) {\n throw new Error(`Invalid ObjectIdentifier: ${id}. Bad number of segments: ${id.pathname.split('/').length}`);\n }\n // biome-ignore lint/style/noNonNullAssertion: tryParse sets identifier when success is true, guarded by the throw above\n return result.identifier!;\n }\n\n public static parseWithCollection(id: URL, collection: string): KeyVaultIdentifier {\n const identifier = KeyVaultIdentifier.parse(id);\n if (identifier.collection.toLowerCase() !== collection.toLowerCase()) {\n throw new Error(`Invalid ObjectIdentifier: ${id}. segment [1] should be '${collection}/', found '${identifier.collection}'`);\n }\n return identifier;\n }\n\n public static tryParse(id: URL | null): { success: boolean; identifier?: KeyVaultIdentifier } {\n if (id === null) {\n return { success: false };\n }\n\n // We expect an identifier with either 3 or 4 segments: host + collection + name [+ version]\n const segments = id.pathname.split('/');\n if (segments.length !== 3 && segments.length !== 4) {\n return { success: false };\n }\n\n const identifier = new KeyVaultIdentifier();\n identifier.id = id;\n identifier.vaultUri = new URL(`${id.protocol}//${id.host}`);\n // biome-ignore lint/style/noNonNullAssertion: length check above guarantees segments[1..3] exist\n identifier.collection = segments[1]!.replace(/\\/$/, ''); // Trim '/'\n // biome-ignore lint/style/noNonNullAssertion: length check above guarantees segments[1..3] exist\n identifier.name = segments[2]!.replace(/\\/$/, ''); // Trim '/'\n // biome-ignore lint/style/noNonNullAssertion: length check above guarantees segments[3] exists when length is 4\n identifier.version = segments.length === 4 ? segments[3]!.replace(/\\/$/, '') : null; // TrimEnd '/'\n\n return { success: true, identifier };\n }\n}\n","/**\n * Port of KeyVaultSecretIdentifier from Azure SDK for .NET\n * @see https://github.com/Azure/azure-sdk-for-net/blob/3dad5181b332bf12d5298810f73347ee1bc9980b/sdk/keyvault/Azure.Security.KeyVault.Secrets/src/KeyVaultSecretIdentifier.cs\n */\n\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nimport { KeyVaultIdentifier } from './KeyVaultIdentifier';\n\n/**\n * Information about a KeyVault Secret parsed from a URL.\n * You can use this information when calling methods of a SecretClient.\n */\nexport class KeyVaultSecretIdentifier {\n /**\n * Gets the source URL passed to KeyVaultSecretIdentifier constructor.\n */\n public sourceId: URL;\n\n /**\n * Gets the URL of the Key Vault.\n */\n public vaultUri: URL;\n\n /**\n * Gets the name of the secret.\n */\n public name: string;\n\n /**\n * Gets the optional version of the secret.\n */\n public version: string | null;\n\n /**\n * Creates a new instance of the KeyVaultSecretIdentifier class.\n * @param id The URL to a secret or deleted secret.\n * @throws Error if id is not a valid Key Vault secret ID.\n */\n public constructor(id: URL) {\n if (id === null || id === undefined) {\n throw new Error('id cannot be null');\n }\n\n const result = KeyVaultIdentifier.tryParse(id);\n if (result.success && result.identifier) {\n this.sourceId = id;\n this.vaultUri = result.identifier.vaultUri;\n this.name = result.identifier.name;\n this.version = result.identifier.version;\n } else {\n throw new Error(`${id} is not a valid secret ID`);\n }\n }\n}\n","/**\n * Port of azure-functions-core-tools reading from local.settings.json\n * @see https://github.com/Azure/azure-functions-core-tools/blob/b367a5155d7bf299c4719dc37051082ae8ddebaf/src/Cli/func/Common/KeyVaultReferencesManager.cs\n */\n\n// Copyright (c) .NET Foundation. All rights reserved.\n// Licensed under the MIT License. See LICENSE in the project root for license information.\n\nimport { DefaultAzureCredential, type TokenCredential } from '@azure/identity';\nimport { SecretClient } from '@azure/keyvault-secrets';\nimport { KeyVaultSecretIdentifier } from './KeyVaultSecretIdentifier';\n\nexport class KeyVaultReferencesManager {\n private static readonly VaultUriSuffix = 'vault.azure.net';\n private static readonly _basicKeyVaultReferenceRegex = /^@Microsoft\\.KeyVault\\((?<ReferenceString>.*)\\)$/;\n\n private readonly _clients = new Map<string, SecretClient>();\n private readonly _credential: TokenCredential = new DefaultAzureCredential(); // CodeQL [SM05137] This is never deployed to production, only used in CLI context in a local dev environment.\n\n public async resolveKeyVaultReferences(settings: { [key: string]: string | undefined }): Promise<void> {\n const keys = Object.keys(settings);\n\n for (const key of keys) {\n try {\n const keyVaultValue = await this.getSecretValue(key, settings[key]);\n if (keyVaultValue != null) {\n settings[key] = keyVaultValue;\n }\n } catch {}\n }\n }\n\n private async getSecretValue(key: string, value: string | undefined): Promise<string | null> {\n const result = this.parseSecret(key, value);\n\n if (result != null) {\n const client = this.getSecretClient(result.uri);\n const secret = await client.getSecret(result.name, result.version ? { version: result.version } : undefined);\n // biome-ignore lint/style/noNonNullAssertion: Key Vault SDK types value as optional but a successfully retrieved secret always has a value in local dev context\n return secret.value!;\n }\n\n return null;\n }\n\n public parseSecret(key: string, value: string | undefined): KeyVaultReferencesManager.ParseSecretResult | null {\n // If the value is null, then we return nothing, as the subsequent call to\n // UpdateEnvironmentVariables(settings) will log to the user that the setting\n // is skipped. We check here, because Regex.Match throws when supplied with a\n // null value.\n if (value == null) {\n return null;\n }\n\n // Determine if the secret value is attempting to use a key vault reference\n const keyVaultReferenceMatch = KeyVaultReferencesManager._basicKeyVaultReferenceRegex.exec(value);\n if (keyVaultReferenceMatch?.groups) {\n const referenceString = keyVaultReferenceMatch.groups['ReferenceString'];\n let result: KeyVaultReferencesManager.ParseSecretResult | null = null;\n try {\n if (referenceString != null) {\n result = this.parseVaultReference(referenceString);\n }\n } catch {\n // ignore and show warning below\n }\n\n // If we detect that a key vault reference was attempted, but did not match any of\n // the supported formats, we write a warning to the console.\n if (result == null) {\n console.warn(`Unable to parse the Key Vault reference for setting: ${key}`);\n }\n\n return result;\n }\n\n return null;\n }\n\n public parseVaultReference(vaultReference: string): KeyVaultReferencesManager.ParseSecretResult | null {\n const secretUriString = this.getValueFromVaultReference('SecretUri', vaultReference);\n if (secretUriString && secretUriString.length > 0) {\n const secretUri = new URL(secretUriString);\n const secretIdentifier = new KeyVaultSecretIdentifier(secretUri);\n return new KeyVaultReferencesManager.ParseSecretResult(secretIdentifier.vaultUri, secretIdentifier.name, secretIdentifier.version);\n }\n\n const vaultName = this.getValueFromVaultReference('VaultName', vaultReference);\n const secretName = this.getValueFromVaultReference('SecretName', vaultReference);\n const version = this.getValueFromVaultReference('SecretVersion', vaultReference);\n if (vaultName && vaultName.length > 0 && secretName && secretName.length > 0) {\n return new KeyVaultReferencesManager.ParseSecretResult(new URL(`https://${vaultName}.${KeyVaultReferencesManager.VaultUriSuffix}`), secretName, version);\n }\n\n return null;\n }\n\n public getValueFromVaultReference(key: string, vaultReference: string): string | null {\n const regex = new RegExp(key + '=(?<Value>[^;]+)(;|$)');\n const match = regex.exec(vaultReference);\n if (match?.groups) {\n return match.groups['Value'] ?? null;\n }\n\n return null;\n }\n\n private getSecretClient(vaultUri: URL): SecretClient {\n const uriString = vaultUri.toString();\n let client = this._clients.get(uriString);\n if (!client) {\n client = new SecretClient(uriString, this._credential);\n this._clients.set(uriString, client);\n }\n return client;\n }\n}\n\nexport namespace KeyVaultReferencesManager {\n export class ParseSecretResult {\n public uri: URL;\n public name: string;\n public version: string | null;\n\n constructor(uri: URL, name: string, version: string | null) {\n this.uri = uri;\n this.name = name;\n this.version = version;\n }\n }\n}\n","/**\n * Port of AppSettingsFile from Azure Functions Core Tools\n * @see https://github.com/Azure/azure-functions-core-tools/blob/b367a5155d7bf299c4719dc37051082ae8ddebaf/src/Cli/func/Common/AppSettingsFile.cs\n */\n\nimport { readFileSync } from 'node:fs';\n\ninterface LocalSettingsJson {\n IsEncrypted?: boolean;\n Values?: Record<string, string>;\n ConnectionStrings?: Record<string, any>;\n Host?: any;\n}\n\nexport class AppSettingsFile {\n public isEncrypted: boolean;\n public values: Record<string, string>;\n public connectionStrings: Record<string, any>;\n public host: any;\n\n constructor(private filePath: string) {\n this.values = {};\n this.connectionStrings = {};\n this.isEncrypted = true;\n\n try {\n const content = readFileSync(this.filePath, 'utf8');\n const appSettings: LocalSettingsJson = JSON.parse(content);\n\n this.isEncrypted = appSettings.IsEncrypted ?? true;\n this.values = appSettings.Values ?? {};\n this.connectionStrings = appSettings.ConnectionStrings ?? {};\n this.host = appSettings.Host ?? {};\n } catch (ex) {\n console.warn(`Failed to read app settings file at '${this.filePath}'. Ensure it is a valid JSON file.`, ex);\n this.values = {};\n this.connectionStrings = {};\n this.isEncrypted = true;\n }\n }\n\n public getValues(): Record<string, string> {\n if (this.isEncrypted) {\n throw new Error('Encrypted settings are not supported in this TypeScript port.');\n }\n return { ...this.values };\n }\n\n public getConnectionStrings(): any[] {\n return [];\n }\n}\n","/**\n * Port of SecretsManager from Azure Functions Core Tools\n * @see https://github.com/Azure/azure-functions-core-tools/blob/b367a5155d7bf299c4719dc37051082ae8ddebaf/src/Cli/func/Common/SecretsManager.cs\n */\n\nimport { join } from 'node:path';\nimport { AppSettingsFile } from './AppSettingsFile';\n\nexport class SecretsManager {\n private static _lazySettings: AppSettingsFile | null = null;\n\n private static get Settings(): AppSettingsFile {\n if (!SecretsManager._lazySettings) {\n SecretsManager._lazySettings = new AppSettingsFile(SecretsManager.AppSettingsFilePath);\n }\n return SecretsManager._lazySettings;\n }\n\n public static get AppSettingsFilePath(): string {\n const secretsFile = 'local.settings.json';\n const rootPath = process.cwd();\n const secretsFilePath = join(rootPath, secretsFile);\n\n console.log(`'${secretsFile}' found in root directory (${rootPath}).`);\n return secretsFilePath;\n }\n\n public static get AppSettingsFileName(): string {\n return 'local.settings.json';\n }\n\n public getSecrets(refreshSecrets = false): Record<string, string> {\n if (refreshSecrets) {\n return new AppSettingsFile(SecretsManager.AppSettingsFilePath).getValues();\n }\n\n return SecretsManager.Settings.getValues();\n }\n\n public getConnectionStrings(): any[] {\n return SecretsManager.Settings.getConnectionStrings();\n }\n}\n","/**\n * Port of StartHostAction from Azure Functions Core Tools (partial)\n * @see https://github.com/Azure/azure-functions-core-tools/blob/b367a5155d7bf299c4719dc37051082ae8ddebaf/src/Cli/func/Actions/HostActions/StartHostAction.cs\n */\n\nimport { env } from 'node:process';\nimport { KeyVaultReferencesManager } from './KeyVaultReferencesManager';\nimport { SecretsManager } from './SecretsManager';\n\nexport class StartHostAction {\n private readonly _secretsManager: SecretsManager;\n private readonly _keyVaultReferencesManager: KeyVaultReferencesManager;\n\n constructor() {\n this._secretsManager = new SecretsManager();\n this._keyVaultReferencesManager = new KeyVaultReferencesManager();\n }\n\n public async buildWebHost(): Promise<void> {\n const settings = await this.getConfigurationSettings('', new URL('http://localhost:7071'));\n await this._keyVaultReferencesManager.resolveKeyVaultReferences(settings);\n this.updateEnvironmentVariables(settings);\n }\n\n private async getConfigurationSettings(scriptPath: string, uri: URL): Promise<Record<string, string>> {\n const settings = this._secretsManager.getSecrets();\n settings['WebsiteHostname'] = uri.host;\n\n const connectionStrings = this._secretsManager.getConnectionStrings();\n for (const connectionString of connectionStrings) {\n settings[`ConnectionStrings:${connectionString.name}`] = connectionString.value;\n }\n settings['AzureWebJobsScriptRoot'] = scriptPath;\n\n const environment: Record<string, string> = {};\n for (const [key, value] of Object.entries(env)) {\n if (typeof value === 'string') {\n environment[key] = value;\n }\n }\n\n if (settings['AZURE_FUNCTIONS_ENVIRONMENT']) {\n const oldValue = settings['AZURE_FUNCTIONS_ENVIRONMENT'];\n console.warn(`AZURE_FUNCTIONS_ENVIRONMENT already exists with value '${oldValue}', overriding to 'Development'.`);\n }\n\n settings['AZURE_FUNCTIONS_ENVIRONMENT'] = 'Development';\n\n return settings;\n }\n\n private updateEnvironmentVariables(secrets: Record<string, string>): void {\n for (const [key, value] of Object.entries(secrets)) {\n if (!key) {\n console.warn('Skipping local setting with empty key.');\n } else if (env[key] !== undefined) {\n console.warn(`Skipping '${key}' from local settings as it's already defined in current environment variables.`);\n } else if (value) {\n env[key] = value;\n } else if (value === '') {\n env[key] = '';\n } else {\n console.warn(`Skipping '${key}' because value is null`);\n }\n }\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ import{__name as t}from"./chunk-7QVYU63E.js";import"regexp.escape/auto";var e=(t=>(t.EsbuildEntryInjection="ESBUILD_ENTRY_INJECTION",t.CjsShimAutoInclude="CJS_SHIM_AUTO_INCLUDE",t))(e||{}),r=class extends Error{static{t(this,"BundlerNotConfiguredError")}constructor(){super("build-azure-local-settings requires esbuild bundle option to be enabled. Without bundling, imports in the generated entry point are not resolved."),this.name="BundlerNotConfiguredError"}},o=class extends Error{static{t(this,"NodePlatformRequiredError")}constructor(t){super(`loadLocalSettings requires platform: 'node', but platform is '${t??"undefined"}'. Either set platform: 'node' or disable loadLocalSettings.`),this.name="NodePlatformRequiredError"}},s="azure-local-settings-ns",n=t((t,e)=>{const r=["/**"," * @generated by @shellicar/build-azure-local-settings",` * @generated-at ${(new Date).toISOString()}`," * WARNING: This code is auto-generated. Do not edit manually."," */",""];"esm"===e&&t.features.CJS_SHIM_AUTO_INCLUDE&&r.push("import '@shellicar/build-azure-local-settings/cjs-shim';");for(const e of t.sideEffectImports)r.push(`import '${e}';`);let o;"default"===t.mainExport?(o="main",r.push(`import ${o} from '${t.mainModule}';`)):(o=t.mainExport,r.push(`import { ${o} } from '${t.mainModule}';`)),t.loadLocalSettings&&r.push("import { loadLocalSettings } from '@shellicar/build-azure-local-settings/runtime';"),r.push("");const s=[];if(t.loadLocalSettings&&s.push("await loadLocalSettings();"),s.push(`await ${o}();`),"cjs"===e){r.push("(async () => {");for(const t of s)r.push(` ${t}`);r.push("})();")}else for(const t of s)r.push(t);return r.join("\n")},"generateVirtualModule"),i=t(t=>`virtual:azure-local-settings/${t}`,"getVirtualModuleId"),a=t((t,e,r)=>{const o=t.entryPoints;Array.isArray(o)?t.entryPoints=[...o,r]:t.entryPoints="object"==typeof o&&null!==o?{...o,[e]:r}:{[e]:r}},"injectEntryPoint"),l=class extends Error{static{t(this,"UnsupportedFormatError")}constructor(t){super(`Unsupported format: ${t}. Only cjs or esm are supported.`),this.name="UnsupportedFormatError"}},u=class extends Error{static{t(this,"UnsupportedPlatformError")}constructor(t){super(`Unsupported platform: ${t??"undefined"}. Only node or neutral are supported when format is not set.`),this.name="UnsupportedPlatformError"}},p=t(t=>{const e=t.define?.TSUP_FORMAT,r=e?JSON.parse(e):t.format;if(r){if("cjs"===r||"esm"===r)return r;throw new l(r)}if("node"===t.platform)return"cjs";if("neutral"===t.platform)return"esm";throw new u(t.platform)},"resolveFormat"),d=t(t=>{const e=i(t.entryName);return{name:"azure-local-settings",setup(i){if(!i.initialOptions.bundle)throw new r;if(t.loadLocalSettings&&"node"!==i.initialOptions.platform)throw new o(i.initialOptions.platform);const l=p(i.initialOptions);t.features.ESBUILD_ENTRY_INJECTION&&a(i.initialOptions,t.entryName,e);const u=new RegExp(`^${RegExp.escape(e)}$`);i.onResolve({filter:u},t=>({path:t.path,namespace:s}));const d=i.initialOptions.absWorkingDir??process.cwd();i.onLoad({filter:/.*/,namespace:s},()=>({contents:n(t,l),loader:"ts",resolveDir:d}))}}},"createPlugin"),c={entryName:"main",mainExport:"default",sideEffectImports:[],loadLocalSettings:!0,debug:!1,features:{ESBUILD_ENTRY_INJECTION:!0,CJS_SHIM_AUTO_INCLUDE:!0}},m=t(t=>({...c,...t,features:{...c.features,...t.features}}),"resolveOptions"),f=t(t=>{if(!t?.mainModule)throw new Error("build-azure-local-settings: mainModule option is required");const e=m(t);return d(e)},"plugin");export{e as Feature,f as esbuild_default};//# sourceMappingURL=chunk-5M5J2O2I.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/enums.ts","../../src/errors/BundlerNotConfiguredError.ts","../../src/errors/NodePlatformRequiredError.ts","../../src/core/consts.ts","../../src/core/generateVirtualModule.ts","../../src/core/getVirtualModuleId.ts","../../src/core/injectEntryPoint.ts","../../src/errors/UnsupportedFormatError.ts","../../src/errors/UnsupportedPlatformError.ts","../../src/core/resolveFormat.ts","../../src/core/createPlugin.ts","../../src/core/defaultOptions.ts","../../src/core/resolveOptions.ts","../../src/core/plugin.ts","../../src/esbuild.ts"],"names":["Feature"],"mappings":";AAEO,IAAK,OAAA,qBAAAA,QAAAA,KAAL;AAML,EAAAA,SAAA,uBAAA,CAAA,GAAwB,yBAAA;AAOxB,EAAAA,SAAA,oBAAA,CAAA,GAAqB,uBAAA;AAbX,EAAA,OAAAA,QAAAA;AAAA,CAAA,EAAA,OAAA,IAAA,EAAA;;;ACEL,IAAM,yBAAA,GAAN,cAAwC,KAAA,CAAM;AAAA,EAJrD;AAIqD,IAAA,MAAA,CAAA,IAAA,EAAA,2BAAA,CAAA;AAAA;AAAA,EAC5C,WAAA,GAAc;AACnB,IAAA,KAAA,CAAM,mJAAwJ,CAAA;AAC9J,IAAA,IAAA,CAAK,IAAA,GAAO,2BAAA;AAAA,EACd;AACF,CAAA;;;ACTO,IAAM,yBAAA,GAAN,cAAwC,KAAA,CAAM;AAAA,EAArD;AAAqD,IAAA,MAAA,CAAA,IAAA,EAAA,2BAAA,CAAA;AAAA;AAAA,EACnD,YAAY,QAAA,EAA8B;AACxC,IAAA,KAAA,CAAM,CAAA,8DAAA,EAAiE,QAAA,IAAY,WAAW,CAAA,4DAAA,CAA8D,CAAA;AAC5J,IAAA,IAAA,CAAK,IAAA,GAAO,2BAAA;AAAA,EACd;AACF,CAAA;;;ACLO,IAAM,UAAA,GAAa,sBAAA;AACnB,IAAM,eAAA,GAAkB,yBAAA;;;ACGxB,IAAM,qBAAA,mBAAwB,MAAA,CAAA,CAAC,OAAA,EAA0B,MAAA,KAAoC;AAClG,EAAA,MAAM,KAAA,GAAkB,CAAC,KAAA,EAAO,wDAAA,EAA0D,C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AAA,CAAA;;;ACLrB,IAAM,cAAA,GAAiC;AAAA,EAC5C,SAAA,EAAW,MAAA;AAAA,EACX,UAAA,EAAY,SAAA;AAAA,EACZ,mBAAmB,EAAC;AAAA,EACpB,iBAAA,EAAmB,IAAA;AAAA,EACnB,KAAA,EAAO,KAAA;AAAA,EACP,QAAA,EAAU;AAAA,IACR,yDAAiC,IAAA;AAAA,IACjC,oDAA8B;AAAA;AAElC,CAAA;;;ACbO,IAAM,cAAA,2BAAkB,YAAA,KAA2C;AACxE,EAAA,MAAM,OAAA,GAAU;AAAA,IACd,GAAG,cAAA;AAAA,IACH,GAAG,YAAA;AAAA,IACH,QAAA,EAAU;AAAA,MACR,GAAG,cAAA,CAAe,QAAA;AAAA,MAClB,GAAG,YAAA,CAAa;AAAA;AAClB,GACF;AAEA,EAAA,OAAO,OAAA;AACT,CAAA,EAX8B,gBAAA,CAAA;;;ACCvB,IAAM,MAAA,2BAAU,YAAA,KAAkC;AACvD,EAAA,IAAI,CAAC,cAAc,UAAA,EAAY;AAC7B,IAAA,MAAM,IAAI,MAAM,2DAA2D,CAAA;AAAA,EAC7E;AAEA,EAAA,MAAM,OAAA,GAAU,eAAe,YAAY,CAAA;AAC3C,EAAA,OAAO,aAAa,OAAO,CAAA;AAC7B,CAAA,EAPsB,QAAA,CAAA;;;ACHtB,IAAO,eAAA,GAAQ","file":"chunk-5M5J2O2I.js","sourcesContent":["import type { Options } from './types';\n\nexport enum Feature {\n /**\n * Enables automatic entry point injection for esbuild.\n * When enabled, `virtual:azure-local-settings/main` is automatically added to esbuild's entryPoints.\n * Note: `main` is the default value of {@link Options.entryName}.\n */\n EsbuildEntryInjection = 'ESBUILD_ENTRY_INJECTION',\n\n /**\n * Enables automatic cjs-shim import for ESM builds.\n * The cjs-shim provides `require`, `__filename`, and `__dirname` globals\n * which are needed when bundling CJS dependencies in ESM output.\n */\n CjsShimAutoInclude = 'CJS_SHIM_AUTO_INCLUDE',\n}\n","/**\n * Error thrown when esbuild's bundle option is not enabled.\n * Without bundling, imports in the virtual entry point are not resolved.\n */\nexport class BundlerNotConfiguredError extends Error {\n public constructor() {\n super('build-azure-local-settings requires esbuild bundle option to be enabled. ' + 'Without bundling, imports in the generated entry point are not resolved.');\n this.name = 'BundlerNotConfiguredError';\n }\n}\n","export class NodePlatformRequiredError extends Error {\n constructor(platform: string | undefined) {\n super(`loadLocalSettings requires platform: 'node', but platform is '${platform ?? 'undefined'}'. Either set platform: 'node' or disable loadLocalSettings.`);\n this.name = 'NodePlatformRequiredError';\n }\n}\n","export const pluginName = 'azure-local-settings';\nexport const pluginNamespace = 'azure-local-settings-ns';\n","import { Feature } from '../enums';\nimport type { SupportedFormat } from './resolveFormat';\nimport type { ResolvedOptions } from './types';\n\nexport const generateVirtualModule = (options: ResolvedOptions, format: SupportedFormat): string => {\n const lines: string[] = ['/**', ' * @generated by @shellicar/build-azure-local-settings', ` * @generated-at ${new Date().toISOString()}`, ' * WARNING: This code is auto-generated. Do not edit manually.', ' */', ''];\n\n if (format === 'esm' && options.features[Feature.CjsShimAutoInclude]) {\n lines.push(\"import '@shellicar/build-azure-local-settings/cjs-shim';\");\n }\n\n for (const importPath of options.sideEffectImports) {\n lines.push(`import '${importPath}';`);\n }\n\n let exportName: string;\n if (options.mainExport === 'default') {\n exportName = 'main';\n lines.push(`import ${exportName} from '${options.mainModule}';`);\n } else {\n exportName = options.mainExport;\n lines.push(`import { ${exportName} } from '${options.mainModule}';`);\n }\n\n if (options.loadLocalSettings) {\n lines.push(\"import { loadLocalSettings } from '@shellicar/build-azure-local-settings/runtime';\");\n }\n\n lines.push('');\n\n const asyncLines: string[] = [];\n if (options.loadLocalSettings) {\n asyncLines.push('await loadLocalSettings();');\n }\n asyncLines.push(`await ${exportName}();`);\n\n if (format === 'cjs') {\n lines.push('(async () => {');\n for (const line of asyncLines) {\n lines.push(` ${line}`);\n }\n lines.push('})();');\n } else {\n for (const line of asyncLines) {\n lines.push(line);\n }\n }\n\n return lines.join('\\n');\n};\n","// Use a path-like format so esbuild uses the basename for output\n\nexport const getVirtualModuleId = (entryName: string): string => `virtual:azure-local-settings/${entryName}`;\n","import type { BuildOptions } from 'esbuild';\n\nexport const injectEntryPoint = (initialOptions: BuildOptions, entryName: string, virtualModuleId: string): void => {\n const entryPoints = initialOptions.entryPoints;\n\n if (Array.isArray(entryPoints)) {\n initialOptions.entryPoints = [...entryPoints, virtualModuleId];\n } else if (typeof entryPoints === 'object' && entryPoints !== null) {\n initialOptions.entryPoints = {\n ...entryPoints,\n [entryName]: virtualModuleId,\n };\n } else {\n initialOptions.entryPoints = { [entryName]: virtualModuleId };\n }\n};\n","export class UnsupportedFormatError extends Error {\n constructor(format: string) {\n super(`Unsupported format: ${format}. Only cjs or esm are supported.`);\n this.name = 'UnsupportedFormatError';\n }\n}\n","export class UnsupportedPlatformError extends Error {\n constructor(platform: string | undefined) {\n super(`Unsupported platform: ${platform ?? 'undefined'}. Only node or neutral are supported when format is not set.`);\n this.name = 'UnsupportedPlatformError';\n }\n}\n","import type { BuildOptions } from 'esbuild';\nimport { UnsupportedFormatError } from '../errors/UnsupportedFormatError';\nimport { UnsupportedPlatformError } from '../errors/UnsupportedPlatformError';\n\nexport type SupportedFormat = 'cjs' | 'esm';\n\n/**\n * Resolves the output format from esbuild options.\n *\n * Checks in order:\n * 1. TSUP_FORMAT define (for tsup compatibility - value is JSON like \"\\\"cjs\\\"\")\n * 2. esbuild format option\n * 3. Platform-based defaults (node → cjs, neutral → esm)\n *\n * @see https://esbuild.github.io/api/#format\n * @see https://github.com/egoist/tsup/blob/b906f86102c02f1ef66ebd4a3f7ff50bdc07af65/src/esbuild/index.ts#L204\n * @throws {UnsupportedFormatError} If format is set to something other than cjs or esm\n * @throws {UnsupportedPlatformError} If format is not set and platform is not node or neutral\n */\nexport const resolveFormat = (initialOptions: BuildOptions): SupportedFormat => {\n // Get format from TSUP_FORMAT (JSON string) or esbuild format option\n const tsupFormat = initialOptions.define?.TSUP_FORMAT;\n const format = tsupFormat ? JSON.parse(tsupFormat) : initialOptions.format;\n\n if (format) {\n if (format === 'cjs' || format === 'esm') {\n return format;\n }\n throw new UnsupportedFormatError(format);\n }\n\n // Format not set - use platform defaults\n if (initialOptions.platform === 'node') {\n return 'cjs';\n }\n if (initialOptions.platform === 'neutral') {\n return 'esm';\n }\n\n throw new UnsupportedPlatformError(initialOptions.platform);\n};\n","import 'regexp.escape/auto';\nimport type { Plugin } from 'esbuild';\nimport { Feature } from '../enums';\nimport { BundlerNotConfiguredError } from '../errors/BundlerNotConfiguredError';\nimport { NodePlatformRequiredError } from '../errors/NodePlatformRequiredError';\nimport { pluginName, pluginNamespace } from './consts';\nimport { generateVirtualModule } from './generateVirtualModule';\nimport { getVirtualModuleId } from './getVirtualModuleId';\nimport { injectEntryPoint } from './injectEntryPoint';\nimport { resolveFormat } from './resolveFormat';\nimport type { ResolvedOptions } from './types';\n\nexport const createPlugin = (options: ResolvedOptions): Plugin => {\n const virtualModuleId = getVirtualModuleId(options.entryName);\n\n return {\n name: pluginName,\n setup(build) {\n if (!build.initialOptions.bundle) {\n throw new BundlerNotConfiguredError();\n }\n\n if (options.loadLocalSettings && build.initialOptions.platform !== 'node') {\n throw new NodePlatformRequiredError(build.initialOptions.platform);\n }\n\n const format = resolveFormat(build.initialOptions);\n\n // Add virtual entry point\n if (options.features[Feature.EsbuildEntryInjection]) {\n injectEntryPoint(build.initialOptions, options.entryName, virtualModuleId);\n }\n\n // Resolve virtual module\n const virtualModuleFilter = new RegExp(`^${RegExp.escape(virtualModuleId)}$`);\n build.onResolve({ filter: virtualModuleFilter }, (args) => ({\n path: args.path,\n namespace: pluginNamespace,\n }));\n\n // Load virtual module content\n const resolveDir = build.initialOptions.absWorkingDir ?? process.cwd();\n build.onLoad({ filter: /.*/, namespace: pluginNamespace }, () => ({\n contents: generateVirtualModule(options, format),\n loader: 'ts',\n resolveDir,\n }));\n },\n };\n};\n","import { Feature } from '../enums';\nimport type { Options } from '../types';\n\ntype DefaultOptions = Omit<Required<Options>, 'mainModule' | 'features'> & {\n features: Record<Feature, boolean>;\n};\n\nexport const defaultOptions: DefaultOptions = {\n entryName: 'main',\n mainExport: 'default',\n sideEffectImports: [],\n loadLocalSettings: true,\n debug: false,\n features: {\n [Feature.EsbuildEntryInjection]: true,\n [Feature.CjsShimAutoInclude]: true,\n },\n};\n","import type { Options } from '../types';\nimport { defaultOptions } from './defaultOptions';\nimport type { ResolvedOptions } from './types';\n\nexport const resolveOptions = (inputOptions: Options): ResolvedOptions => {\n const options = {\n ...defaultOptions,\n ...inputOptions,\n features: {\n ...defaultOptions.features,\n ...inputOptions.features,\n },\n } satisfies ResolvedOptions;\n\n return options;\n};\n","import type { Plugin } from 'esbuild';\nimport type { Options } from '../types';\nimport { createPlugin } from './createPlugin';\nimport { resolveOptions } from './resolveOptions';\n\nexport const plugin = (inputOptions: Options): Plugin => {\n if (!inputOptions?.mainModule) {\n throw new Error('build-azure-local-settings: mainModule option is required');\n }\n\n const options = resolveOptions(inputOptions);\n return createPlugin(options);\n};\n","import { plugin } from './core/plugin';\n\nexport default plugin;\n"]}
@@ -0,0 +1 @@
1
+ var e=Object.defineProperty,r=(r,a)=>e(r,"name",{value:a,configurable:!0});export{r as __name};//# sourceMappingURL=chunk-7QVYU63E.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-7QVYU63E.js"}
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1 @@
1
+ import{createRequire as o}from"node:module";import e from"node:path";import m from"node:url";globalThis.require=o(import.meta.url),globalThis.__filename=m.fileURLToPath(import.meta.url),globalThis.__dirname=e.dirname(__filename);//# sourceMappingURL=cjs-shim.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cjs-shim.ts"],"names":[],"mappings":";AAIA,UAAA,CAAW,OAAA,GAAU,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AAClD,UAAA,CAAW,UAAA,GAAa,GAAA,CAAI,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AACzD,UAAA,CAAW,SAAA,GAAY,IAAA,CAAK,OAAA,CAAQ,UAAU,CAAA","file":"cjs-shim.js","sourcesContent":["import { createRequire } from 'node:module';\nimport path from 'node:path';\nimport url from 'node:url';\n\nglobalThis.require = createRequire(import.meta.url);\nglobalThis.__filename = url.fileURLToPath(import.meta.url);\nglobalThis.__dirname = path.dirname(__filename);\n"]}
@@ -0,0 +1,6 @@
1
+ import plugin from './index.js';
2
+ import 'esbuild';
3
+
4
+
5
+
6
+ export { plugin as default };
@@ -0,0 +1 @@
1
+ export{esbuild_default as default}from"./chunk-5M5J2O2I.js";import"./chunk-7QVYU63E.js";//# sourceMappingURL=esbuild.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"esbuild.js"}
@@ -0,0 +1,61 @@
1
+ import { Plugin } from 'esbuild';
2
+
3
+ declare enum Feature {
4
+ /**
5
+ * Enables automatic entry point injection for esbuild.
6
+ * When enabled, `virtual:azure-local-settings/main` is automatically added to esbuild's entryPoints.
7
+ * Note: `main` is the default value of {@link Options.entryName}.
8
+ */
9
+ EsbuildEntryInjection = "ESBUILD_ENTRY_INJECTION",
10
+ /**
11
+ * Enables automatic cjs-shim import for ESM builds.
12
+ * The cjs-shim provides `require`, `__filename`, and `__dirname` globals
13
+ * which are needed when bundling CJS dependencies in ESM output.
14
+ */
15
+ CjsShimAutoInclude = "CJS_SHIM_AUTO_INCLUDE"
16
+ }
17
+
18
+ interface Options {
19
+ /**
20
+ * The name for the entry point in esbuild's entryPoints
21
+ * @default 'main'
22
+ * @example 'main'
23
+ */
24
+ entryName?: string;
25
+ /**
26
+ * Path to the main module to import and run
27
+ * @example './src/main.ts'
28
+ */
29
+ mainModule: string;
30
+ /**
31
+ * The export to import from mainModule.
32
+ * Use 'default' for default exports, or specify a named export.
33
+ * @default 'default'
34
+ */
35
+ mainExport?: string;
36
+ /**
37
+ * Side-effect imports to include before the main module
38
+ * These are imports that execute code on load (e.g., 'dotenv/config')
39
+ * @example ['dotenv/config', './cjs-shim']
40
+ */
41
+ sideEffectImports?: string[];
42
+ /**
43
+ * Whether to load local.settings.json with Key Vault reference resolution
44
+ * @default true
45
+ */
46
+ loadLocalSettings?: boolean;
47
+ /**
48
+ * Enable debug logging
49
+ * @default false
50
+ */
51
+ debug?: boolean;
52
+ /**
53
+ * Feature flags for bundler-specific functionality
54
+ */
55
+ features?: Features;
56
+ }
57
+ type Features = Partial<Record<Feature, boolean>>;
58
+
59
+ declare const plugin: (inputOptions: Options) => Plugin;
60
+
61
+ export { Feature, type Features, type Options, plugin as default, plugin };
@@ -0,0 +1 @@
1
+ export{Feature,esbuild_default as default,esbuild_default as plugin}from"./chunk-5M5J2O2I.js";import"./chunk-7QVYU63E.js";//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,3 @@
1
+ declare const loadLocalSettings: () => Promise<void>;
2
+
3
+ export { loadLocalSettings };
@@ -0,0 +1 @@
1
+ import{__name as t}from"./chunk-7QVYU63E.js";var o=t(async()=>{const{StartHostAction:t}=await import("./StartHostAction-IGJTX6EF.js"),o=new t;await o.buildWebHost()},"loadLocalSettings");export{o as loadLocalSettings};//# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/local-settings/loadLocalSettings.ts"],"names":[],"mappings":";AAAO,IAAM,oCAAoB,MAAA,CAAA,YAA2B;AAC1D,EAAA,MAAM,EAAE,eAAA,EAAgB,GAAI,MAAM,OAAO,+BAAmB,CAAA;AAC5D,EAAA,MAAM,IAAA,GAAO,IAAI,eAAA,EAAgB;AACjC,EAAA,MAAM,KAAK,YAAA,EAAa;AAC1B,CAAA,EAJiC,mBAAA","file":"runtime.js","sourcesContent":["export const loadLocalSettings = async (): Promise<void> => {\n const { StartHostAction } = await import('./StartHostAction');\n const host = new StartHostAction();\n await host.buildWebHost();\n};\n"]}
package/package.json ADDED
@@ -0,0 +1,116 @@
1
+ {
2
+ "name": "@shellicar/build-azure-local-settings",
3
+ "private": false,
4
+ "version": "1.0.0",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Stephen Hellicar",
8
+ "description": "Build plugin that loads Azure local.settings.json with Key Vault reference resolution for non-Azure-Functions apps.",
9
+ "keywords": [
10
+ "esbuild",
11
+ "tsup",
12
+ "azure",
13
+ "local-settings",
14
+ "key-vault",
15
+ "azure-functions",
16
+ "plugin"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/shellicar/build-azure-local-settings.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/shellicar/build-azure-local-settings/issues"
24
+ },
25
+ "homepage": "https://github.com/shellicar/build-azure-local-settings#readme",
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "exports": {
30
+ ".": {
31
+ "import": {
32
+ "types": "./dist/esm/index.d.ts",
33
+ "default": "./dist/esm/index.js"
34
+ },
35
+ "require": {
36
+ "types": "./dist/cjs/index.d.cts",
37
+ "default": "./dist/cjs/index.cjs"
38
+ }
39
+ },
40
+ "./esbuild": {
41
+ "import": {
42
+ "types": "./dist/esm/esbuild.d.ts",
43
+ "default": "./dist/esm/esbuild.js"
44
+ },
45
+ "require": {
46
+ "types": "./dist/cjs/esbuild.d.cts",
47
+ "default": "./dist/cjs/esbuild.cjs"
48
+ }
49
+ },
50
+ "./runtime": {
51
+ "import": {
52
+ "types": "./dist/esm/runtime.d.ts",
53
+ "default": "./dist/esm/runtime.js"
54
+ },
55
+ "require": {
56
+ "types": "./dist/cjs/runtime.d.cts",
57
+ "default": "./dist/cjs/runtime.cjs"
58
+ }
59
+ },
60
+ "./cjs-shim": {
61
+ "import": {
62
+ "default": "./dist/esm/cjs-shim.js"
63
+ }
64
+ }
65
+ },
66
+ "main": "./dist/cjs/index.cjs",
67
+ "module": "./dist/esm/index.js",
68
+ "types": "./dist/esm/index.d.ts",
69
+ "typesVersions": {
70
+ "*": {
71
+ "index": [
72
+ "./dist/esm/index.d.ts"
73
+ ],
74
+ "esbuild": [
75
+ "./dist/esm/esbuild.d.ts"
76
+ ],
77
+ "runtime": [
78
+ "./dist/esm/runtime.d.ts"
79
+ ]
80
+ }
81
+ },
82
+ "files": [
83
+ "dist",
84
+ "*.md"
85
+ ],
86
+ "peerDependencies": {
87
+ "esbuild": "*"
88
+ },
89
+ "peerDependenciesMeta": {
90
+ "esbuild": {
91
+ "optional": true
92
+ }
93
+ },
94
+ "dependencies": {
95
+ "@azure/identity": "^4.13.0",
96
+ "@azure/keyvault-secrets": "^4.10.0",
97
+ "regexp.escape": "^2.0.1"
98
+ },
99
+ "devDependencies": {
100
+ "@shellicar/build-clean": "^1.3.0",
101
+ "@tsconfig/node22": "^22.0.5",
102
+ "@types/node": "^25.4.0",
103
+ "@types/regexp.escape": "^2.0.0",
104
+ "esbuild": "*",
105
+ "terser": "^5.46.0",
106
+ "tsup": "^8.5.1",
107
+ "typescript": "^5.9.3",
108
+ "vitest": "^4.0.18"
109
+ },
110
+ "scripts": {
111
+ "build": "tsup",
112
+ "dev": "tsup --watch",
113
+ "test": "vitest run",
114
+ "type-check": "tsc -p tsconfig.check.json"
115
+ }
116
+ }