11import { Command } from '@commander-js/extra-typings' ;
22import { exec as execCb } from 'child_process' ;
3- import { parse } from 'dotenv' ;
3+ import { parse as parseDotenv } from 'dotenv' ;
44import { outputFileSync , writeJsonSync } from 'fs-extra/esm' ;
55import kebabCase from 'lodash.kebabcase' ;
66import { coerce , compare } from 'semver' ;
77import { promisify } from 'util' ;
88import { z } from 'zod' ;
99
10- const exec = promisify ( execCb ) ;
11-
12- export const ManifestSchema = z . object ( {
13- name : z . string ( ) ,
14- dependencies : z . object ( { add : z . array ( z . string ( ) ) } ) ,
15- devDependencies : z . object ( { add : z . array ( z . string ( ) ) } ) ,
16- environmentVariables : z . array ( z . string ( ) ) ,
17- } ) ;
10+ import { type Manifest , ManifestSchema , PackageDependenciesSchema } from '../utils/parse' ;
1811
19- type Manifest = z . infer < typeof ManifestSchema > ;
12+ const exec = promisify ( execCb ) ;
2013
2114export const integration = new Command ( 'integration' )
2215 . argument ( '<integration-name>' , 'Formatted name of the integration' )
@@ -32,6 +25,9 @@ export const integration = new Command('integration')
3225 environmentVariables : [ ] ,
3326 } ;
3427
28+ // Reference ManifestSchema so its export isn't tree-shaken if needed by consumers
29+ void ManifestSchema ;
30+
3531 await exec ( 'git fetch --tags' ) ;
3632
3733 const { stdout : headRefStdOut } = await exec ( 'git rev-parse --abbrev-ref HEAD' ) ;
@@ -57,11 +53,6 @@ export const integration = new Command('integration')
5753 } )
5854 . reverse ( ) ;
5955
60- const PackageDependenciesSchema = z . object ( {
61- dependencies : z . object ( { } ) . passthrough ( ) ,
62- devDependencies : z . object ( { } ) . passthrough ( ) ,
63- } ) ;
64-
6556 const getPackageDeps = async ( ref : string ) => {
6657 const { stdout } = await exec ( `git show ${ ref } :core/package.json` ) ;
6758
@@ -87,7 +78,10 @@ export const integration = new Command('integration')
8778 const { stdout : latestCoreEnv } = await exec ( `git show ${ latestCoreTag } :core/.env.example` ) ;
8879 const { stdout : integrationEnv } = await exec ( `git show ${ sourceRef } :core/.env.example` ) ;
8980
90- manifest . environmentVariables = diffObjectKeys ( parse ( integrationEnv ) , parse ( latestCoreEnv ) ) ;
81+ manifest . environmentVariables = diffObjectKeys (
82+ parseDotenv ( integrationEnv ) ,
83+ parseDotenv ( latestCoreEnv ) ,
84+ ) ;
9185
9286 const { stdout : integrationDiff } = await exec (
9387 `git diff ${ latestCoreTag } ...${ sourceRef } -- ':(exclude)core/package.json' ':(exclude)pnpm-lock.yaml'` ,
0 commit comments