Skip to content

[BUG]: @generateTypes doesn't create variables when using custom path with varlock typegen #548

@bestickley

Description

@bestickley

varlock version

0.7.0

Steps to reproduce

cat .env.infra.schema
# @defaultSensitive=false
# @generateTypes(lang=ts, path=./infra/env.d.ts)
# ---
TEST_A_B="1"
TEST_A_C="1"%                                                                                                                                                                                                      
stat ./infra/env.d.ts
stat: ./infra/env.d.ts: stat: No such file or directory
pnpm varlock typegen --path .env.infra.schema
✅ Types generated successfully
cat infra/env.d.ts

// 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑
// 🛑 THIS IS AN AUTOGENERATED FILE - DO NOT EDIT DIRECTLY 🛑
// 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑

// @ts-nocheck
/* eslint-disable */
export type CoercedEnvSchema = {
};


declare module 'varlock/env' {
  export interface TypedEnvSchema extends Readonly<CoercedEnvSchema> {}
  export interface PublicTypedEnvSchema extends Readonly<Pick<CoercedEnvSchema, ''>> {}
}


export type EnvSchemaAsStrings = {
  [Property in keyof CoercedEnvSchema]:
    CoercedEnvSchema[Property] extends string ? CoercedEnvSchema[Property]
      : (CoercedEnvSchema[Property] extends boolean ? ('true' | 'false') : string)
};

declare global {

  // add types for global import.meta.env
  interface ImportMetaEnv extends EnvSchemaAsStrings {}
  interface ImportMeta {
    readonly env: ImportMetaEnv;
  }

  // add types for global process.env
  namespace NodeJS {
    interface ProcessEnv extends EnvSchemaAsStrings {}
  }
}%  

BUT, then no path:

cat .env.schema
# @defaultSensitive=false
# @generateTypes(lang=ts, path=env.d.ts)
# @import(
#   ../../../,
#   AWS_ACCOUNT,
#   AWS_PROFILE,
#   AWS_REGION,
#   DEPLOY_ENV,
#   IS_LOCAL,
#   NAMESPACE,
#   SHARED_INFRA_NAMESPACE,
# )
# @import(
#   ../shared-infra/.env.export.schema,
#   OS_DOMAIN_ENDPOINT,
#   OS_READ_ROLE_ARN,
#   PGUSER,
#   PGDATABASE,
#   PGHOST,
#   PGHOST_RO,
# )
rm env.d.ts
rm: env.d.ts: No such file or directory
pnpm varlock typegen
✅ Types generated successfully
cat env.d.ts

// 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑
// 🛑 THIS IS AN AUTOGENERATED FILE - DO NOT EDIT DIRECTLY 🛑
// 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑 🛑

// @ts-nocheck
/* eslint-disable */
export type CoercedEnvSchema = {
  /**
   * **AWS_ACCOUNT**  
   * AWS Account ID  
   * ![icon](data:image/svg+xml;utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2032%2032%22%3E%3Cpath%20fill%3D%22%23808080%22%20d%3D%22M29%2022h-5a2.003%202.003%200%200%201-2-2v-6a2%202%200%200%201%202-2h5v2h-5v6h5ZM18%2012h-4V8h-2v14h6a2.003%202.003%200%200%200%202-2v-6a2%202%200%200%200-2-2m-4%208v-6h4v6Zm-6-8H3v2h5v2H4a2%202%200%200%200-2%202v2a2%202%200%200%200%202%202h6v-8a2%202%200%200%200-2-2m0%208H4v-2h4Z%22%2F%3E%3C%2Fsvg%3E)   
   */
  AWS_ACCOUNT: string;
  
  /**
   * **AWS_PROFILE**  
   * name of `[profile ...]` in ~/.aws/config  
   * ![icon](data:image/svg+xml;utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2032%2032%22%3E%3Cpath%20fill%3D%22%23808080%22%20d%3D%22M29%2022h-5a2.003%202.003%200%200%201-2-2v-6a2%202%200%200%201%202-2h5v2h-5v6h5ZM18%2012h-4V8h-2v14h6a2.003%202.003%200%200%200%202-2v-6a2%202%200%200%200-2-2m-4%208v-6h4v6Zm-6-8H3v2h5v2H4a2%202%200%200%200-2%202v2a2%202%200%200%200%202%202h6v-8a2%202%200%200%200-2-2m0%208H4v-2h4Z%22%2F%3E%3C%2Fsvg%3E)   
   */
  AWS_PROFILE: string;
  
  /**
   * **AWS_REGION**  
   * AWS Region  
   * ![icon](data:image/svg+xml;utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2032%2032%22%3E%3Cpath%20fill%3D%22%23808080%22%20d%3D%22M29%2022h-5a2.003%202.003%200%200%201-2-2v-6a2%202%200%200%201%202-2h5v2h-5v6h5ZM18%2012h-4V8h-2v14h6a2.003%202.003%200%200%200%202-2v-6a2%202%200%200%200-2-2m-4%208v-6h4v6Zm-6-8H3v2h5v2H4a2%202%200%200%200-2%202v2a2%202%200%200%200%202%202h6v-8a2%202%200%200%200-2-2m0%208H4v-2h4Z%22%2F%3E%3C%2Fsvg%3E)   
   */
  AWS_REGION: string;
  
  /**
   * **DEPLOY_ENV**  
   * Defines environment which the application will be deployed  
   * Included in CloudFormation Stack Names  
   * ![icon](data:image/svg+xml;utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22%23808080%22%20d%3D%22M7.885%2010.23L12%203.463l4.116%206.769zm9.606%2011q-1.558%200-2.64-1.081t-1.082-2.64t1.082-2.649t2.64-1.09t2.649%201.09t1.09%202.649t-1.09%202.64t-2.649%201.082m-13.722-.5v-6.462h6.462v6.462z%22%2F%3E%3C%2Fsvg%3E)   
   */
  DEPLOY_ENV: "dev" | "test" | "prod";
  
  /**
   * **IS_LOCAL**  
   * Flag for if code is running locally on developer's laptjop. Useful to know  
   * whether we need to use local port forwarding or not for DB.  
   * ![icon](data:image/svg+xml;utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2032%2032%22%3E%3Cpath%20fill%3D%22%23808080%22%20d%3D%22M23%2023a7%207%200%201%201%207-7a7.01%207.01%200%200%201-7%207m0-12a5%205%200%201%200%205%205a5.006%205.006%200%200%200-5-5%22%2F%3E%3Ccircle%20cx%3D%229%22%20cy%3D%2216%22%20r%3D%227%22%20fill%3D%22%23808080%22%2F%3E%3C%2Fsvg%3E)   
   */
  IS_LOCAL: boolean;
  
  /**
   * **NAMESPACE**  
   * Namespace prefixed in all CloudFormation stacks and resources. Derived from  
   * the current git branch so each branch gets isolated infrastructure.  
   * Sanitized to DNS-safe label: non-alphanumeric → hyphens.  
   * ![icon](data:image/svg+xml;utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2032%2032%22%3E%3Cpath%20fill%3D%22%23808080%22%20d%3D%22M29%2022h-5a2.003%202.003%200%200%201-2-2v-6a2%202%200%200%201%202-2h5v2h-5v6h5ZM18%2012h-4V8h-2v14h6a2.003%202.003%200%200%200%202-2v-6a2%202%200%200%200-2-2m-4%208v-6h4v6Zm-6-8H3v2h5v2H4a2%202%200%200%200-2%202v2a2%202%200%200%200%202%202h6v-8a2%202%200%200%200-2-2m0%208H4v-2h4Z%22%2F%3E%3C%2Fsvg%3E)   
   */
  NAMESPACE: string;
  
  /**
   * **SHARED_INFRA_NAMESPACE**  
   * Namespace for shared infrastructure (apps/data/shared-infra) that needs to be  
   * known by other apps for importing infrastructure. Using namespace for shared-infra  
   * allows for blue/green deployment in future if needed.  
   * ![icon](data:image/svg+xml;utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2032%2032%22%3E%3Cpath%20fill%3D%22%23808080%22%20d%3D%22M29%2022h-5a2.003%202.003%200%200%201-2-2v-6a2%202%200%200%201%202-2h5v2h-5v6h5ZM18%2012h-4V8h-2v14h6a2.003%202.003%200%200%200%202-2v-6a2%202%200%200%200-2-2m-4%208v-6h4v6Zm-6-8H3v2h5v2H4a2%202%200%200%200-2%202v2a2%202%200%200%200%202%202h6v-8a2%202%200%200%200-2-2m0%208H4v-2h4Z%22%2F%3E%3C%2Fsvg%3E)   
   */
  SHARED_INFRA_NAMESPACE: string;
  
  /**
   * **OS_DOMAIN_ENDPOINT**  
   * ![icon](data:image/svg+xml;utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2032%2032%22%3E%3Cpath%20fill%3D%22%23808080%22%20d%3D%22M29%2022h-5a2.003%202.003%200%200%201-2-2v-6a2%202%200%200%201%202-2h5v2h-5v6h5ZM18%2012h-4V8h-2v14h6a2.003%202.003%200%200%200%202-2v-6a2%202%200%200%200-2-2m-4%208v-6h4v6Zm-6-8H3v2h5v2H4a2%202%200%200%200-2%202v2a2%202%200%200%200%202%202h6v-8a2%202%200%200%200-2-2m0%208H4v-2h4Z%22%2F%3E%3C%2Fsvg%3E)   
   */
  OS_DOMAIN_ENDPOINT: string;
  
  /**
   * **OS_READ_ROLE_ARN**  
   * ![icon](data:image/svg+xml;utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2032%2032%22%3E%3Cpath%20fill%3D%22%23808080%22%20d%3D%22M29%2022h-5a2.003%202.003%200%200%201-2-2v-6a2%202%200%200%201%202-2h5v2h-5v6h5ZM18%2012h-4V8h-2v14h6a2.003%202.003%200%200%200%202-2v-6a2%202%200%200%200-2-2m-4%208v-6h4v6Zm-6-8H3v2h5v2H4a2%202%200%200%200-2%202v2a2%202%200%200%200%202%202h6v-8a2%202%200%200%200-2-2m0%208H4v-2h4Z%22%2F%3E%3C%2Fsvg%3E)   
   */
  OS_READ_ROLE_ARN: string;
  
  /**
   * **PGUSER**  
   * ![icon](data:image/svg+xml;utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2032%2032%22%3E%3Cpath%20fill%3D%22%23808080%22%20d%3D%22M29%2022h-5a2.003%202.003%200%200%201-2-2v-6a2%202%200%200%201%202-2h5v2h-5v6h5ZM18%2012h-4V8h-2v14h6a2.003%202.003%200%200%200%202-2v-6a2%202%200%200%200-2-2m-4%208v-6h4v6Zm-6-8H3v2h5v2H4a2%202%200%200%200-2%202v2a2%202%200%200%200%202%202h6v-8a2%202%200%200%200-2-2m0%208H4v-2h4Z%22%2F%3E%3C%2Fsvg%3E)   
   */
  PGUSER: string;
  
  /**
   * **PGDATABASE**  
   * ![icon](data:image/svg+xml;utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2032%2032%22%3E%3Cpath%20fill%3D%22%23808080%22%20d%3D%22M29%2022h-5a2.003%202.003%200%200%201-2-2v-6a2%202%200%200%201%202-2h5v2h-5v6h5ZM18%2012h-4V8h-2v14h6a2.003%202.003%200%200%200%202-2v-6a2%202%200%200%200-2-2m-4%208v-6h4v6Zm-6-8H3v2h5v2H4a2%202%200%200%200-2%202v2a2%202%200%200%200%202%202h6v-8a2%202%200%200%200-2-2m0%208H4v-2h4Z%22%2F%3E%3C%2Fsvg%3E)   
   */
  PGDATABASE: string;
  
  /**
   * **PGHOST**  
   * ![icon](data:image/svg+xml;utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2032%2032%22%3E%3Cpath%20fill%3D%22%23808080%22%20d%3D%22M29%2022h-5a2.003%202.003%200%200%201-2-2v-6a2%202%200%200%201%202-2h5v2h-5v6h5ZM18%2012h-4V8h-2v14h6a2.003%202.003%200%200%200%202-2v-6a2%202%200%200%200-2-2m-4%208v-6h4v6Zm-6-8H3v2h5v2H4a2%202%200%200%200-2%202v2a2%202%200%200%200%202%202h6v-8a2%202%200%200%200-2-2m0%208H4v-2h4Z%22%2F%3E%3C%2Fsvg%3E)   
   */
  PGHOST: string;
  
  /**
   * **PGHOST_RO**  
   * ![icon](data:image/svg+xml;utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2032%2032%22%3E%3Cpath%20fill%3D%22%23808080%22%20d%3D%22M29%2022h-5a2.003%202.003%200%200%201-2-2v-6a2%202%200%200%201%202-2h5v2h-5v6h5ZM18%2012h-4V8h-2v14h6a2.003%202.003%200%200%200%202-2v-6a2%202%200%200%200-2-2m-4%208v-6h4v6Zm-6-8H3v2h5v2H4a2%202%200%200%200-2%202v2a2%202%200%200%200%202%202h6v-8a2%202%200%200%200-2-2m0%208H4v-2h4Z%22%2F%3E%3C%2Fsvg%3E)   
   */
  PGHOST_RO: string;
  
};


declare module 'varlock/env' {
  export interface TypedEnvSchema extends Readonly<CoercedEnvSchema> {}
  export interface PublicTypedEnvSchema extends Readonly<Pick<CoercedEnvSchema, 'AWS_ACCOUNT' | 'AWS_PROFILE' | 'AWS_REGION' | 'DEPLOY_ENV' | 'IS_LOCAL' | 'NAMESPACE' | 'SHARED_INFRA_NAMESPACE' | 'OS_DOMAIN_ENDPOINT' | 'OS_READ_ROLE_ARN' | 'PGUSER' | 'PGDATABASE' | 'PGHOST' | 'PGHOST_RO'>> {}
}


export type EnvSchemaAsStrings = {
  [Property in keyof CoercedEnvSchema]:
    CoercedEnvSchema[Property] extends string ? CoercedEnvSchema[Property]
      : (CoercedEnvSchema[Property] extends boolean ? ('true' | 'false') : string)
};

declare global {

  // add types for global import.meta.env
  interface ImportMetaEnv extends EnvSchemaAsStrings {}
  interface ImportMeta {
    readonly env: ImportMetaEnv;
  }

  // add types for global process.env
  namespace NodeJS {
    interface ProcessEnv extends EnvSchemaAsStrings {}
  }
}%     

What is expected?

cating the infra/env.d.ts would show TEST_A_B and TEST_A_C variables

What is actually happening?

generated .d.ts file is empty for .env.infra.schema for works for .env.schema

System Info

npx envinfo --system --npmPackages

  System:
    OS: macOS 26.4
    CPU: (12) arm64 Apple M3 Pro
    Memory: 824.23 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  npmPackages:
    @census/shared-core: workspace:^ => 0.1.0 
    @census/shared-infra: workspace:^ => 0.1.0 
    @types/aws-lambda: catalog: => 8.10.161 
    aws-cdk: catalog: => 2.1115.1 
    aws-cdk-lib: catalog: => 2.246.0 
    cdk-nag: catalog: => 2.37.55 
    constructs: catalog: => 10.6.0

Any additional comments?

No response

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions