@gigadrive/network-config 0.0.1 → 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/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import c from"ajv";import f from"ajv-formats";import{parseVercelBuildOutputV3 as d}from"./build-output-v3/parse";import{parseRawConfig as l}from"./parse-raw-config";import{parseConfigV4 as g}from"./v4/parse";import u from"./v4/schema.json";const $=async(a,t)=>{const r=await l(a),o=r.version,p={4:u},n=a.replace("/tmp/unzipped/",""),s=p[o];if(!s)throw new Error(`Config file at ${n} has an unsupported version: ${o}`);const e=new c;f(e);const m=e.compile(s);if(!m(r))throw new Error(`Config file at ${n} is invalid: ${e.errorsText(m.errors)}`);let i=await{4:g}[o](r,t);return i=await d(i,t),i};export{$ as parseConfig};
1
+ import m from"ajv";import c from"ajv-formats";import f from"fs";import g from"path";import{parseVercelBuildOutputV3 as d}from"./build-output-v3/parse";import{parseRawConfig as u}from"./parse-raw-config";import{parseConfigV4 as h}from"./v4/parse";import v from"./v4/schema.json";const y=["gigadrive.yaml","gigadrive.yml","nebula.yaml","nebula.yml","nebula.json"],V=e=>{for(const t of y){const r=g.join(e,t);if(f.existsSync(r))return r}return null},$=async(e,t)=>{const r=await u(e),n=r.version,l={4:v},i=e.replace("/tmp/unzipped/",""),a=l[n];if(!a)throw new Error(`Config file at ${i} has an unsupported version: ${n}`);const s=new m;c(s);const p=s.compile(a);if(!p(r))throw new Error(`Config file at ${i} is invalid: ${s.errorsText(p.errors)}`);let o=await{4:h}[n](r,t);return o=await d(o,t),o.entrypoints.length===0&&(o.assets?.paths?.length||0)===0?o.warnings.push("The current project does not have any functions or assets to deploy."):o.entrypoints.length===0&&(o.assets?.paths?.length||0)===0&&o.routes.length===0&&o.errors.push("The current project config does not resolve to any functions, assets or routes and can not be deployed."),o};export{y as ALLOWED_CONFIG_NAMES,V as findConfig,$ as parseConfig};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["import Ajv from 'ajv';\nimport addFormats from 'ajv-formats';\nimport { parseVercelBuildOutputV3 } from './build-output-v3/parse';\nimport type { NormalizedConfig } from './normalized-config';\nimport { parseRawConfig } from './parse-raw-config';\nimport { parseConfigV4 } from './v4/parse';\nimport schemaV4 from './v4/schema.json';\n\nexport const parseConfig = async (filePath: string, projectFolder: string): Promise<NormalizedConfig> => {\n const parsed = await parseRawConfig(filePath);\n const version = parsed.version;\n\n const schemaMap: Record<number, object> = {\n /*1: schemaV1,\n 2: schemaV2,\n 3: schemaV3,*/\n 4: schemaV4,\n };\n\n // build the path to the config file relative to the project root (strip /tmp/unzipped prefix)\n const relativePath = filePath.replace('/tmp/unzipped/', '');\n\n const schema = schemaMap[version];\n\n if (!schema) {\n throw new Error(`Config file at ${relativePath} has an unsupported version: ${version}`);\n }\n\n // validate the config file\n const ajv = new Ajv();\n addFormats(ajv);\n\n const validate = ajv.compile(schema);\n\n const valid = validate(parsed);\n if (!valid) {\n throw new Error(`Config file at ${relativePath} is invalid: ${ajv.errorsText(validate.errors)}`);\n }\n\n // @ts-ignore\n const parserMap: Record<number, (config, projectFolder) => Promise<NormalizedConfig>> = {\n /*1: parseConfigV1,\n 2: parseConfigV2,\n 3: parseConfigV3,*/\n 4: parseConfigV4,\n };\n\n let parseResult: NormalizedConfig = await parserMap[version](parsed, projectFolder);\n\n // TODO: apply transformers\n parseResult = await parseVercelBuildOutputV3(parseResult, projectFolder);\n\n return parseResult;\n};\n"],
5
- "mappings": "AAAA,OAAOA,MAAS,MAChB,OAAOC,MAAgB,cACvB,OAAS,4BAAAC,MAAgC,0BAEzC,OAAS,kBAAAC,MAAsB,qBAC/B,OAAS,iBAAAC,MAAqB,aAC9B,OAAOC,MAAc,mBAEd,MAAMC,EAAc,MAAOC,EAAkBC,IAAqD,CACvG,MAAMC,EAAS,MAAMN,EAAeI,CAAQ,EACtCG,EAAUD,EAAO,QAEjBE,EAAoC,CAIxC,EAAGN,CACL,EAGMO,EAAeL,EAAS,QAAQ,iBAAkB,EAAE,EAEpDM,EAASF,EAAUD,CAAO,EAEhC,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,kBAAkBD,CAAY,gCAAgCF,CAAO,EAAE,EAIzF,MAAMI,EAAM,IAAId,EAChBC,EAAWa,CAAG,EAEd,MAAMC,EAAWD,EAAI,QAAQD,CAAM,EAGnC,GAAI,CADUE,EAASN,CAAM,EAE3B,MAAM,IAAI,MAAM,kBAAkBG,CAAY,gBAAgBE,EAAI,WAAWC,EAAS,MAAM,CAAC,EAAE,EAWjG,IAAIC,EAAgC,KAPoD,CAItF,EAAGZ,CACL,EAEoDM,CAAO,EAAED,EAAQD,CAAa,EAGlF,OAAAQ,EAAc,MAAMd,EAAyBc,EAAaR,CAAa,EAEhEQ,CACT",
6
- "names": ["Ajv", "addFormats", "parseVercelBuildOutputV3", "parseRawConfig", "parseConfigV4", "schemaV4", "parseConfig", "filePath", "projectFolder", "parsed", "version", "schemaMap", "relativePath", "schema", "ajv", "validate", "parseResult"]
4
+ "sourcesContent": ["import Ajv from 'ajv';\nimport addFormats from 'ajv-formats';\nimport fs from 'fs';\nimport path from 'path';\nimport { parseVercelBuildOutputV3 } from './build-output-v3/parse';\nimport type { NormalizedConfig } from './normalized-config';\nimport { parseRawConfig } from './parse-raw-config';\nimport { parseConfigV4 } from './v4/parse';\nimport schemaV4 from './v4/schema.json';\n\nexport const ALLOWED_CONFIG_NAMES = ['gigadrive.yaml', 'gigadrive.yml', 'nebula.yaml', 'nebula.yml', 'nebula.json'];\n\n/**\n * Finds a config file in the project folder.\n * @param projectFolder The folder to search for a config file in.\n * @returns The path to the config file, or null if no config file is found.\n */\nexport const findConfig = (projectFolder: string): string | null => {\n for (const name of ALLOWED_CONFIG_NAMES) {\n const filePath = path.join(projectFolder, name);\n if (fs.existsSync(filePath)) {\n return filePath;\n }\n }\n return null;\n};\n\nexport const parseConfig = async (filePath: string, projectFolder: string): Promise<NormalizedConfig> => {\n const parsed = await parseRawConfig(filePath);\n const version = parsed.version;\n\n const schemaMap: Record<number, object> = {\n /*1: schemaV1,\n 2: schemaV2,\n 3: schemaV3,*/\n 4: schemaV4,\n };\n\n // build the path to the config file relative to the project root (strip /tmp/unzipped prefix)\n const relativePath = filePath.replace('/tmp/unzipped/', '');\n\n const schema = schemaMap[version];\n\n if (!schema) {\n throw new Error(`Config file at ${relativePath} has an unsupported version: ${version}`);\n }\n\n // validate the config file\n const ajv = new Ajv();\n addFormats(ajv);\n\n const validate = ajv.compile(schema);\n\n const valid = validate(parsed);\n if (!valid) {\n throw new Error(`Config file at ${relativePath} is invalid: ${ajv.errorsText(validate.errors)}`);\n }\n\n // @ts-ignore\n const parserMap: Record<number, (config, projectFolder) => Promise<NormalizedConfig>> = {\n /*1: parseConfigV1,\n 2: parseConfigV2,\n 3: parseConfigV3,*/\n 4: parseConfigV4,\n };\n\n let parseResult: NormalizedConfig = await parserMap[version](parsed, projectFolder);\n\n // TODO: apply transformers\n parseResult = await parseVercelBuildOutputV3(parseResult, projectFolder);\n\n // if the config does not resolve to any resources, warn the user\n if (parseResult.entrypoints.length === 0 && (parseResult.assets?.paths?.length || 0) === 0) {\n parseResult.warnings.push('The current project does not have any functions or assets to deploy.');\n } else if (\n parseResult.entrypoints.length === 0 &&\n (parseResult.assets?.paths?.length || 0) === 0 &&\n parseResult.routes.length === 0\n ) {\n parseResult.errors.push(\n 'The current project config does not resolve to any functions, assets or routes and can not be deployed.'\n );\n }\n\n return parseResult;\n};\n"],
5
+ "mappings": "AAAA,OAAOA,MAAS,MAChB,OAAOC,MAAgB,cACvB,OAAOC,MAAQ,KACf,OAAOC,MAAU,OACjB,OAAS,4BAAAC,MAAgC,0BAEzC,OAAS,kBAAAC,MAAsB,qBAC/B,OAAS,iBAAAC,MAAqB,aAC9B,OAAOC,MAAc,mBAEd,MAAMC,EAAuB,CAAC,iBAAkB,gBAAiB,cAAe,aAAc,aAAa,EAOrGC,EAAcC,GAAyC,CAClE,UAAWC,KAAQH,EAAsB,CACvC,MAAMI,EAAWT,EAAK,KAAKO,EAAeC,CAAI,EAC9C,GAAIT,EAAG,WAAWU,CAAQ,EACxB,OAAOA,CAEX,CACA,OAAO,IACT,EAEaC,EAAc,MAAOD,EAAkBF,IAAqD,CACvG,MAAMI,EAAS,MAAMT,EAAeO,CAAQ,EACtCG,EAAUD,EAAO,QAEjBE,EAAoC,CAIxC,EAAGT,CACL,EAGMU,EAAeL,EAAS,QAAQ,iBAAkB,EAAE,EAEpDM,EAASF,EAAUD,CAAO,EAEhC,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,kBAAkBD,CAAY,gCAAgCF,CAAO,EAAE,EAIzF,MAAMI,EAAM,IAAInB,EAChBC,EAAWkB,CAAG,EAEd,MAAMC,EAAWD,EAAI,QAAQD,CAAM,EAGnC,GAAI,CADUE,EAASN,CAAM,EAE3B,MAAM,IAAI,MAAM,kBAAkBG,CAAY,gBAAgBE,EAAI,WAAWC,EAAS,MAAM,CAAC,EAAE,EAWjG,IAAIC,EAAgC,KAPoD,CAItF,EAAGf,CACL,EAEoDS,CAAO,EAAED,EAAQJ,CAAa,EAGlF,OAAAW,EAAc,MAAMjB,EAAyBiB,EAAaX,CAAa,EAGnEW,EAAY,YAAY,SAAW,IAAMA,EAAY,QAAQ,OAAO,QAAU,KAAO,EACvFA,EAAY,SAAS,KAAK,sEAAsE,EAEhGA,EAAY,YAAY,SAAW,IAClCA,EAAY,QAAQ,OAAO,QAAU,KAAO,GAC7CA,EAAY,OAAO,SAAW,GAE9BA,EAAY,OAAO,KACjB,yGACF,EAGKA,CACT",
6
+ "names": ["Ajv", "addFormats", "fs", "path", "parseVercelBuildOutputV3", "parseRawConfig", "parseConfigV4", "schemaV4", "ALLOWED_CONFIG_NAMES", "findConfig", "projectFolder", "name", "filePath", "parseConfig", "parsed", "version", "schemaMap", "relativePath", "schema", "ajv", "validate", "parseResult"]
7
7
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@gigadrive/network-config",
3
- "version": "0.0.1",
3
+ "version": "1.0.0",
4
4
  "devDependencies": {
5
- "esbuild": "^0.24.0"
5
+ "esbuild": "^0.25.0"
6
6
  },
7
7
  "files": [
8
8
  "dist"