From 1ec997aa82419011b47ef62539295f19fea35dc1 Mon Sep 17 00:00:00 2001 From: Brian Burns Date: Sun, 7 Jul 2024 02:48:30 -0500 Subject: [PATCH] wip --- packages/cli/lib/services/compile.service.ts | 13 +++++++------ .../cli/lib/services/compile.service.unit.test.ts | 13 ------------- .../cli/lib/services/model.service.unit.test.ts | 2 -- packages/cli/lib/sync.unit.cli-test.ts | 2 +- vite.cli.config.ts | 1 + 5 files changed, 9 insertions(+), 22 deletions(-) diff --git a/packages/cli/lib/services/compile.service.ts b/packages/cli/lib/services/compile.service.ts index 5c0d59ea3a4..c9bd405bc12 100644 --- a/packages/cli/lib/services/compile.service.ts +++ b/packages/cli/lib/services/compile.service.ts @@ -44,15 +44,16 @@ export async function compileAllFiles({ const parsed = res.response!; const compilerOptions = (JSON.parse(tsconfig) as { compilerOptions: Record }).compilerOptions; - if (debug) { - printDebug(`Compiler options: ${JSON.stringify(compilerOptions, null, 2)}`); - } const compiler = tsNode.create({ skipProject: true, // when installed locally we don't want ts-node to pick up the package tsconfig.json file compilerOptions }); + if (debug) { + printDebug(`Compiler options: ${JSON.stringify(compilerOptions, null, 2)}`); + } + let scriptDirectory: string | undefined; if (scriptName && providerConfigKey && type) { scriptDirectory = resolveTsFileLocation({ fullPath, scriptName, providerConfigKey, type }).replace(fullPath, ''); @@ -60,8 +61,8 @@ export async function compileAllFiles({ } const integrationFiles = listFilesToCompile({ scriptName, fullPath, scriptDirectory, parsed, debug }); - let success = true; + for (const file of integrationFiles) { try { const completed = await compile({ fullPath, file, parsed, compiler, debug }); @@ -332,9 +333,9 @@ export function listFilesToCompile({ // get file paths that match the given path parts, // with last part treated as a file extension. // eg getMatchingFiles('bar', 'ts') -> glob.sync('bar/*.ts') +// note: glob needs posix paths for input, so use slash fn function getMatchingFiles(...args: string[]): string[] { args.splice(-1, 1, `*.${args.slice(-1)[0]}`); - // note: glob needs posix paths for input, so use slash fn - const pattern = slash(args.join('/')); // eg 'bar/*.ts' + const pattern = slash(args.join('/')); return glob.sync(pattern); } diff --git a/packages/cli/lib/services/compile.service.unit.test.ts b/packages/cli/lib/services/compile.service.unit.test.ts index 75812666e9f..d329d03664b 100644 --- a/packages/cli/lib/services/compile.service.unit.test.ts +++ b/packages/cli/lib/services/compile.service.unit.test.ts @@ -4,27 +4,14 @@ import { getFileToCompile, listFilesToCompile } from './compile.service'; import { fileURLToPath } from 'node:url'; import type { NangoYamlParsed } from '@nangohq/types'; -// eg "C:\\Users\bburns\\Workspace\\forks\\nango\\packages\\cli\\lib\\services" const thisFolder = path.dirname(fileURLToPath(import.meta.url)); -// function join(...args) { -// args = args.map(arg => ) -// return path.join(...args) -// } - describe('listFiles', () => { it('should list files with glob', () => { const files = listFilesToCompile({ fullPath: thisFolder, parsed: { integrations: [], models: new Map(), yamlVersion: 'v2' } }); expect(files.length).toBeGreaterThan(1); - //. why should this be the first entry? expect(files[0]).toStrictEqual({ baseName: 'verification.service', - //. but listFiles gives - // 'packages\\cli\\lib\\services\\verification.service.ts' - // why? - // that's relative to curdir, not fullpath - // oh, that's what glob does - wew - // path.relative(join..., '') inputPath: join(thisFolder, 'verification.service.ts'), outputPath: join(thisFolder, 'dist/verification.service.js') }); diff --git a/packages/cli/lib/services/model.service.unit.test.ts b/packages/cli/lib/services/model.service.unit.test.ts index 7f84566066e..363726d799d 100644 --- a/packages/cli/lib/services/model.service.unit.test.ts +++ b/packages/cli/lib/services/model.service.unit.test.ts @@ -173,11 +173,9 @@ describe('fieldToTypescript', () => { describe('generate exports', () => { describe('json', () => { it('should export to JSON', () => { - // const folderTS = `/tmp/cli-exports-json`; const folderTS = join(os.tmpdir(), 'cli-exports-json'); fs.rmSync(folderTS, { recursive: true, force: true }); fs.mkdirSync(folderTS, { recursive: true }); - // const pathTS = path.join(`/tmp/cli-exports-json`, 'schema.ts'); const pathTS = join(folderTS, 'schema.ts'); fs.writeFileSync(pathTS, `export interface Test { id: string; name: number[]; }`); diff --git a/packages/cli/lib/sync.unit.cli-test.ts b/packages/cli/lib/sync.unit.cli-test.ts index 0788f3bc7d8..93bdd8cee47 100644 --- a/packages/cli/lib/sync.unit.cli-test.ts +++ b/packages/cli/lib/sync.unit.cli-test.ts @@ -8,7 +8,7 @@ import { exampleSyncName } from './constants.js'; import { compileAllFiles, compileSingleFile, getFileToCompile } from './services/compile.service.js'; import { getNangoRootPath } from './utils.js'; import parserService from './services/parser.service.js'; -import { copyDirectoryAndContents, removeVersion, getTestDirectory, fixturesPath } from './tests/helpers.js'; +import { copyDirectoryAndContents, removeVersion, fixturesPath, getTestDirectory } from './tests/helpers.js'; import { parse } from './services/config.service.js'; describe('generate function tests', () => { diff --git a/vite.cli.config.ts b/vite.cli.config.ts index f150faaf513..055352f79b0 100644 --- a/vite.cli.config.ts +++ b/vite.cli.config.ts @@ -10,6 +10,7 @@ export default defineConfig({ env: { NANGO_ENCRYPTION_KEY: 'RzV4ZGo5RlFKMm0wYWlXdDhxTFhwb3ZrUG5KNGg3TmU=' }, + testTimeout: 20000, chaiConfig: { truncateThreshold: 10000 },