From 69b72bd570cab2a27456e3e90186a1dcdaf188cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20=C5=BDia=C4=8Dik?= Date: Sat, 16 Sep 2023 19:06:24 +0200 Subject: [PATCH] feat(azure-func): publish executor --- packages/azure-func/CHANGELOG.md | 9 +- packages/azure-func/executors.json | 5 + packages/azure-func/package.json | 4 +- .../src/executors/publish/executor.spec.ts | 225 ++++++++++++++++++ .../src/executors/publish/executor.ts | 43 ++++ .../src/executors/publish/schema.d.ts | 5 + .../src/executors/publish/schema.json | 24 ++ .../src/executors/serve/executor.ts | 36 +-- .../src/executors/serve/schema.d.ts | 7 +- packages/util/.eslintrc.json | 25 ++ packages/util/.swcrc | 24 ++ packages/util/README.md | 11 + packages/util/jest.config.ts | 11 + packages/util/package.json | 9 + packages/util/project.json | 41 ++++ packages/util/src/index.ts | 4 + packages/util/src/lib/getBuildOptions.ts | 10 + packages/util/src/lib/getBuildTarget.ts | 26 ++ .../util/src/lib/schemaWithBuildTarget.ts | 4 + packages/util/src/lib/spawnSyncChecked.ts | 14 ++ packages/util/tsconfig.json | 16 ++ packages/util/tsconfig.lib.json | 11 + packages/util/tsconfig.spec.json | 9 + tsconfig.base.json | 3 +- 24 files changed, 538 insertions(+), 38 deletions(-) create mode 100644 packages/azure-func/src/executors/publish/executor.spec.ts create mode 100644 packages/azure-func/src/executors/publish/executor.ts create mode 100644 packages/azure-func/src/executors/publish/schema.d.ts create mode 100644 packages/azure-func/src/executors/publish/schema.json create mode 100644 packages/util/.eslintrc.json create mode 100644 packages/util/.swcrc create mode 100644 packages/util/README.md create mode 100644 packages/util/jest.config.ts create mode 100644 packages/util/package.json create mode 100644 packages/util/project.json create mode 100644 packages/util/src/index.ts create mode 100644 packages/util/src/lib/getBuildOptions.ts create mode 100644 packages/util/src/lib/getBuildTarget.ts create mode 100644 packages/util/src/lib/schemaWithBuildTarget.ts create mode 100644 packages/util/src/lib/spawnSyncChecked.ts create mode 100644 packages/util/tsconfig.json create mode 100644 packages/util/tsconfig.lib.json create mode 100644 packages/util/tsconfig.spec.json diff --git a/packages/azure-func/CHANGELOG.md b/packages/azure-func/CHANGELOG.md index cef4e3e..4c939e3 100644 --- a/packages/azure-func/CHANGELOG.md +++ b/packages/azure-func/CHANGELOG.md @@ -7,11 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.3.0] - 2023-09-16 + +### Added + +- `publish` executor added. + ## [0.2.0] - 2023-09-15 ### Changed - `serve` now watches the project for changes. -[unreleased]: https://github.com/ziacik/nx-tools/compare/azure-func-0.2.0...HEAD +[unreleased]: https://github.com/ziacik/nx-tools/compare/azure-func-0.3.0...HEAD +[0.3.0]: https://github.com/ziacik/nx-tools/compare/azure-func-0.3.0...azure-func-0.2.0 [0.2.0]: https://github.com/ziacik/nx-tools/releases/tag/azure-func-0.2.0 diff --git a/packages/azure-func/executors.json b/packages/azure-func/executors.json index f6ae6c3..c77676a 100644 --- a/packages/azure-func/executors.json +++ b/packages/azure-func/executors.json @@ -4,6 +4,11 @@ "implementation": "./src/executors/serve/executor", "schema": "./src/executors/serve/schema.json", "description": "serve executor" + }, + "publish": { + "implementation": "./src/executors/publish/executor", + "schema": "./src/executors/publish/schema.json", + "description": "Publishes the azure func application to Azure." } } } diff --git a/packages/azure-func/package.json b/packages/azure-func/package.json index a54165d..157f8c6 100644 --- a/packages/azure-func/package.json +++ b/packages/azure-func/package.json @@ -1,13 +1,13 @@ { "name": "@ziacik/azure-func", - "version": "0.2.0", + "version": "0.3.0", "dependencies": { "@nx/devkit": "16.8.1", "@nx/js": "16.8.1", "@nx/linter": "16.8.1", "@nx/node": "16.8.1", "@swc/helpers": "~0.5.0", - "chalk": "^4.1.2" + "@ziacik/util": "1.0.0" }, "type": "commonjs", "main": "./src/index.js", diff --git a/packages/azure-func/src/executors/publish/executor.spec.ts b/packages/azure-func/src/executors/publish/executor.spec.ts new file mode 100644 index 0000000..d8f9acc --- /dev/null +++ b/packages/azure-func/src/executors/publish/executor.spec.ts @@ -0,0 +1,225 @@ +import * as devkit from '@nx/devkit'; +import { ExecutorContext, Target } from '@nx/devkit'; +import * as childProcess from 'child_process'; +import executor from './executor'; +import { PublishExecutorSchema } from './schema'; + +describe('Publish Executor', () => { + let context: ExecutorContext; + let options: PublishExecutorSchema; + let npmProcessResult: BuildResult; + let funcProcessResult: BuildResult; + + beforeEach(() => { + npmProcessResult = 'succeed'; + funcProcessResult = 'succeed'; + + context = { + root: '/root', + cwd: '/current', + isVerbose: false, + projectName: 'my-app', + targetName: 'build', + configurationName: 'production', + taskGraph: { + roots: [], + dependencies: {}, + tasks: {}, + }, + projectGraph: { + nodes: { + 'my-app': { + type: 'app', + name: 'my-app', + data: { + root: '/root', + targets: { + build: { + options: { + some: 'option', + }, + }, + }, + }, + }, + }, + dependencies: {}, + }, + projectsConfigurations: { + version: 1, + projects: { + 'my-app': { + projectType: 'application', + root: '/root', + targets: { + build: { + executor: '@ziacik/azure-func:serve', + }, + }, + }, + }, + }, + }; + + options = { + azureAppName: 'some-azure-app', + buildTarget: 'my-app:build:production', + buildTargetOptions: { + some: 'build-option', + }, + }; + + jest.spyOn(console, 'error').mockImplementation((e) => { + throw new Error('Console error: ' + e); + }); + + jest.spyOn(devkit, 'readTargetOptions').mockImplementation((target: Target) => ({ + outputPath: `/some/path/dist/${target.project}`, + })); + + jest.spyOn(childProcess, 'spawnSync').mockImplementation((command) => { + const result = command === 'npm' ? npmProcessResult : command === 'func' ? funcProcessResult : 'terminate'; + + if (result === 'succeed') { + return { pid: 123, status: 0, output: [], stdout: '', stderr: '', signal: null }; + } else if (result === 'fail') { + return { pid: 123, status: 1, output: [], stdout: '', stderr: '', signal: null }; + } else { + throw new Error('Process spawn error.'); + } + }); + }); + + it('runs the build target first', async () => { + buildWill('succeed'); + npmProcessWill('succeed'); + const { success } = await executor(options, context); + expect(success).toBe(true); + expect(devkit.runExecutor).toHaveBeenCalledTimes(1); + expect(devkit.runExecutor).toHaveBeenCalledWith( + { + configuration: 'production', + project: 'my-app', + target: 'build', + }, + { + some: 'build-option', + watch: false, + }, + context + ); + }); + + it('if the build fails, we fail', async () => { + buildWill('fail'); + const { success } = await executor(options, context); + expect(success).toBe(false); + }); + + it('if subsequent build fails, we fail', async () => { + buildWill('succeed', 'succeed', 'fail'); + const { success } = await executor(options, context); + expect(success).toBe(false); + }); + + it('will not start dependency installation if the build fails', async () => { + buildWill('fail'); + await executor(options, context); + expect(childProcess.spawnSync).not.toHaveBeenCalled(); + }); + + it('installs dependencies in the dist dir after build', async () => { + buildWill('succeed'); + npmProcessWill('fail'); + await executor(options, context); + expect(childProcess.spawnSync).toHaveBeenCalledWith('npm', ['install', '--omit=dev'], { + cwd: '/root/some/path/dist/my-app', + stdio: 'inherit', + }); + }); + + it('if installing dependencies fails, we fail', async () => { + buildWill('succeed'); + npmProcessWill('fail'); + const { success } = await executor(options, context); + expect(success).toBe(false); + }); + + it('if installing dependencies throws, we fail', async () => { + buildWill('succeed'); + npmProcessWill('terminate'); + expectConsoleError(); + const { success } = await executor(options, context); + expect(success).toBe(false); + expect(console.error).toHaveBeenCalledWith(new Error('Process spawn error.')); + }); + + it('will not start publish if npm i fails', async () => { + buildWill('succeed'); + npmProcessWill('fail'); + await executor(options, context); + expect(childProcess.spawnSync).toHaveBeenCalledWith('npm', expect.anything(), expect.anything()); + expect(childProcess.spawnSync).not.toHaveBeenCalledWith('func', expect.anything(), expect.anything()); + }); + + it('runs func to publish the app to azure', async () => { + buildWill('succeed'); + npmProcessWill('succeed'); + funcProcessWill('succeed'); + await executor(options, context); + expect(childProcess.spawnSync).toHaveBeenCalledWith('func', ['azure', 'functionapp', 'publish', 'some-azure-app'], { + cwd: '/root/some/path/dist/my-app', + stdio: 'inherit', + }); + }); + + it('if publish terminates, we fail', async () => { + buildWill('succeed'); + npmProcessWill('succeed'); + funcProcessWill('terminate'); + expectConsoleError(); + const output = await executor(options, context); + expect(output.success).toBe(false); + expect(console.error).toHaveBeenCalledWith(new Error('Process spawn error.')); + }); + + it('if publish fails, we fail', async () => { + buildWill('succeed'); + npmProcessWill('succeed'); + funcProcessWill('fail'); + const output = await executor(options, context); + expect(output.success).toBe(false); + }); + + type BuildResult = 'succeed' | 'fail' | 'terminate'; + + function npmProcessWill(what: BuildResult): void { + npmProcessResult = what; + } + + function funcProcessWill(what: BuildResult): void { + funcProcessResult = what; + } + + function buildWill(...what: BuildResult[]): void { + jest.spyOn(devkit, 'runExecutor').mockResolvedValue( + (async function* () { + for (const buildResult of what) { + if (buildResult === 'terminate') { + return { success: false }; + } else { + yield { + success: buildResult === 'succeed', + }; + } + } + + return { success: true }; + })() + ); + } +}); + +function expectConsoleError() { + jest.mocked(console.error).mockImplementation(); +} diff --git a/packages/azure-func/src/executors/publish/executor.ts b/packages/azure-func/src/executors/publish/executor.ts new file mode 100644 index 0000000..ae248c2 --- /dev/null +++ b/packages/azure-func/src/executors/publish/executor.ts @@ -0,0 +1,43 @@ +import { ExecutorContext, runExecutor } from '@nx/devkit'; +import { getBuildOptions, getBuildTarget, spawnSyncChecked } from '@ziacik/util'; +import { join } from 'path'; +import { PublishExecutorSchema } from './schema'; + +export default async function runPublishExecutor(options: PublishExecutorSchema, context: ExecutorContext): Promise<{ success: boolean }> { + process.env['NODE_ENV'] ??= context?.configurationName ?? 'development'; + + const buildTarget = getBuildTarget(options, context); + + const buildIterator = await runExecutor(buildTarget, { ...options.buildTargetOptions, watch: false }, context); + + for await (const buildResult of buildIterator) { + if (!buildResult.success) { + return buildResult; + } + } + + const buildOptions = getBuildOptions(buildTarget, options, context); + const distDir = join(context.root, buildOptions.outputPath); + + const npmResult = buildDependenciesInDist(distDir); + + if (!npmResult.success) { + return npmResult; + } + + return publishDist(distDir, options.azureAppName); +} + +function buildDependenciesInDist(distDir: string): { success: boolean } { + return spawnSyncChecked('npm', ['install', '--omit=dev'], { + cwd: distDir, + stdio: 'inherit', + }); +} + +function publishDist(distDir: string, azureAppName: string): { success: boolean } { + return spawnSyncChecked('func', ['azure', 'functionapp', 'publish', azureAppName], { + cwd: distDir, + stdio: 'inherit', + }); +} diff --git a/packages/azure-func/src/executors/publish/schema.d.ts b/packages/azure-func/src/executors/publish/schema.d.ts new file mode 100644 index 0000000..b2d7a10 --- /dev/null +++ b/packages/azure-func/src/executors/publish/schema.d.ts @@ -0,0 +1,5 @@ +import { SchemaWithBuildTarget } from '@ziacik/util'; + +export interface PublishExecutorSchema extends SchemaWithBuildTarget { + azureAppName: string; +} diff --git a/packages/azure-func/src/executors/publish/schema.json b/packages/azure-func/src/executors/publish/schema.json new file mode 100644 index 0000000..761988d --- /dev/null +++ b/packages/azure-func/src/executors/publish/schema.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://json-schema.org/schema", + "version": 2, + "title": "Publish executor", + "description": "", + "type": "object", + "properties": { + "azureAppName": { + "type": "string", + "description": "Name of the target azure function application on Azure." + }, + "buildTarget": { + "type": "string", + "description": "The target to run to build you the app." + }, + "buildTargetOptions": { + "type": "object", + "description": "Additional options to pass into the build target.", + "default": {} + } + }, + "additionalProperties": false, + "required": ["azureAppName", "buildTarget"] +} diff --git a/packages/azure-func/src/executors/serve/executor.ts b/packages/azure-func/src/executors/serve/executor.ts index 2286d2f..601c58d 100644 --- a/packages/azure-func/src/executors/serve/executor.ts +++ b/packages/azure-func/src/executors/serve/executor.ts @@ -1,32 +1,13 @@ -import { ExecutorContext, Target, parseTargetString, readTargetOptions, runExecutor } from '@nx/devkit'; -import { ExecutorOptions } from '@nx/js/src/utils/schema'; -import * as chalk from 'chalk'; +import { ExecutorContext, Target, runExecutor } from '@nx/devkit'; +import { getBuildOptions, getBuildTarget } from '@ziacik/util'; import { ChildProcess, spawn } from 'child_process'; import { join } from 'path'; import { ServeExecutorSchema } from './schema'; -export default async function runxExecutor(options: ServeExecutorSchema, context: ExecutorContext) { +export default async function runServeExecutor(options: ServeExecutorSchema, context: ExecutorContext) { process.env['NODE_ENV'] ??= context?.configurationName ?? 'development'; - if (context.projectName == null) { - throw new Error('ProjectName undefined in executor context.'); - } - - if (context.projectGraph == null) { - throw new Error('ProjectName undefined in executor context.'); - } - - const project = context.projectGraph.nodes[context.projectName]; - - if (project.data.targets == null) { - throw new Error('Project targets undefined in executor context.'); - } - - const buildTarget = parseTargetString(options.buildTarget, context.projectGraph); - - if (!project.data.targets[buildTarget.target]) { - throw new Error(`Cannot find build target ${chalk.bold(options.buildTarget)} for project ${chalk.bold(context.projectName)}`); - } + const buildTarget = getBuildTarget(options, context); const buildIterator = await runExecutor(buildTarget, { ...options.buildTargetOptions, watch: true }, context); let buildResult = await buildIterator.next(); @@ -62,13 +43,8 @@ async function waitForSuccessfulBuild( } function runAzureFunction(buildTarget: Target, options: ServeExecutorSchema, context: ExecutorContext) { - const buildOptions: ExecutorOptions = { - ...readTargetOptions(buildTarget, context), - ...options.buildTargetOptions, - }; - - const outputPath = buildOptions.outputPath; - const distDir = join(context.root, outputPath); + const buildOptions = getBuildOptions(buildTarget, options, context); + const distDir = join(context.root, buildOptions.outputPath); const funcProcess = spawn('func', ['host', 'start', '--language-worker', '--', '--inspect=9229'], { cwd: distDir, diff --git a/packages/azure-func/src/executors/serve/schema.d.ts b/packages/azure-func/src/executors/serve/schema.d.ts index 3f4f228..4fe4b07 100644 --- a/packages/azure-func/src/executors/serve/schema.d.ts +++ b/packages/azure-func/src/executors/serve/schema.d.ts @@ -1,4 +1,3 @@ -export interface ServeExecutorSchema { - buildTargetOptions: Record; - buildTarget: string; -} +import { SchemaWithBuildTarget } from '@ziacik/util'; + +export type ServeExecutorSchema = SchemaWithBuildTarget; diff --git a/packages/util/.eslintrc.json b/packages/util/.eslintrc.json new file mode 100644 index 0000000..a3648b3 --- /dev/null +++ b/packages/util/.eslintrc.json @@ -0,0 +1,25 @@ +{ + "extends": ["../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": "error" + } + } + ] +} diff --git a/packages/util/.swcrc b/packages/util/.swcrc new file mode 100644 index 0000000..57f888f --- /dev/null +++ b/packages/util/.swcrc @@ -0,0 +1,24 @@ +{ + "jsc": { + "target": "es2017", + "parser": { + "syntax": "typescript", + "decorators": true, + "dynamicImport": true + }, + "transform": { + "decoratorMetadata": true, + "legacyDecorator": true + }, + "keepClassNames": true, + "externalHelpers": true, + "loose": true + }, + "module": { + "type": "commonjs", + "strict": true, + "noInterop": true + }, + "sourceMaps": true, + "exclude": ["jest.config.ts", ".*\\.spec.tsx?$", ".*\\.test.tsx?$", "./src/jest-setup.ts$", "./**/jest-setup.ts$", ".*.js$"] +} diff --git a/packages/util/README.md b/packages/util/README.md new file mode 100644 index 0000000..b28c0cc --- /dev/null +++ b/packages/util/README.md @@ -0,0 +1,11 @@ +# util + +Common utils library. + +## Building + +Run `nx build util` to build the library. + +## Running unit tests + +Run `nx test util` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/packages/util/jest.config.ts b/packages/util/jest.config.ts new file mode 100644 index 0000000..6c59d4a --- /dev/null +++ b/packages/util/jest.config.ts @@ -0,0 +1,11 @@ +/* eslint-disable */ +export default { + displayName: 'util', + preset: '../../jest.preset.js', + testEnvironment: 'node', + transform: { + '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], + }, + moduleFileExtensions: ['ts', 'js', 'html'], + coverageDirectory: '../../coverage/packages/util', +}; diff --git a/packages/util/package.json b/packages/util/package.json new file mode 100644 index 0000000..7d5a667 --- /dev/null +++ b/packages/util/package.json @@ -0,0 +1,9 @@ +{ + "name": "@ziacik/util", + "version": "1.0.0", + "dependencies": { + "@nx/devkit": "16.8.1", + "@nx/js": "16.8.1", + "@swc/helpers": "~0.5.0" + } +} diff --git a/packages/util/project.json b/packages/util/project.json new file mode 100644 index 0000000..2803462 --- /dev/null +++ b/packages/util/project.json @@ -0,0 +1,41 @@ +{ + "name": "util", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/util/src", + "projectType": "library", + "targets": { + "build": { + "executor": "@nx/js:swc", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/packages/util", + "tsConfig": "packages/util/tsconfig.lib.json", + "packageJson": "packages/util/package.json", + "main": "packages/util/src/index.ts", + "assets": ["packages/util/*.md"] + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["packages/util/**/*.ts", "packages/util/package.json"] + } + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "packages/util/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + } + }, + "tags": [] +} diff --git a/packages/util/src/index.ts b/packages/util/src/index.ts new file mode 100644 index 0000000..65a1398 --- /dev/null +++ b/packages/util/src/index.ts @@ -0,0 +1,4 @@ +export * from './lib/getBuildOptions'; +export * from './lib/getBuildTarget'; +export * from './lib/schemaWithBuildTarget'; +export * from './lib/spawnSyncChecked'; diff --git a/packages/util/src/lib/getBuildOptions.ts b/packages/util/src/lib/getBuildOptions.ts new file mode 100644 index 0000000..0bec8ba --- /dev/null +++ b/packages/util/src/lib/getBuildOptions.ts @@ -0,0 +1,10 @@ +import { ExecutorContext, Target, readTargetOptions } from '@nx/devkit'; +import { ExecutorOptions } from '@nx/js/src/utils/schema'; +import { SchemaWithBuildTarget } from './schemaWithBuildTarget'; + +export function getBuildOptions(buildTarget: Target, options: SchemaWithBuildTarget, context: ExecutorContext): ExecutorOptions { + return { + ...readTargetOptions(buildTarget, context), + ...options.buildTargetOptions, + }; +} diff --git a/packages/util/src/lib/getBuildTarget.ts b/packages/util/src/lib/getBuildTarget.ts new file mode 100644 index 0000000..8182d1a --- /dev/null +++ b/packages/util/src/lib/getBuildTarget.ts @@ -0,0 +1,26 @@ +import { ExecutorContext, Target, parseTargetString } from '@nx/devkit'; +import { SchemaWithBuildTarget } from './schemaWithBuildTarget'; + +export function getBuildTarget(options: SchemaWithBuildTarget, context: ExecutorContext): Target { + if (context.projectName == null) { + throw new Error('ProjectName undefined in executor context.'); + } + + if (context.projectGraph == null) { + throw new Error('ProjectName undefined in executor context.'); + } + + const project = context.projectGraph.nodes[context.projectName]; + + if (project.data.targets == null) { + throw new Error('Project targets undefined in executor context.'); + } + + const buildTarget = parseTargetString(options.buildTarget, context.projectGraph); + + if (!project.data.targets[buildTarget.target]) { + throw new Error(`Cannot find build target options.buildTarget for project context.projectName`); + } + + return buildTarget; +} diff --git a/packages/util/src/lib/schemaWithBuildTarget.ts b/packages/util/src/lib/schemaWithBuildTarget.ts new file mode 100644 index 0000000..c8481cb --- /dev/null +++ b/packages/util/src/lib/schemaWithBuildTarget.ts @@ -0,0 +1,4 @@ +export interface SchemaWithBuildTarget { + buildTargetOptions: Record; + buildTarget: string; +} diff --git a/packages/util/src/lib/spawnSyncChecked.ts b/packages/util/src/lib/spawnSyncChecked.ts new file mode 100644 index 0000000..c63a559 --- /dev/null +++ b/packages/util/src/lib/spawnSyncChecked.ts @@ -0,0 +1,14 @@ +import { SpawnSyncOptions, spawnSync } from 'child_process'; + +export function spawnSyncChecked(command: string, args?: ReadonlyArray, options?: SpawnSyncOptions): { success: boolean } { + try { + const { status } = spawnSync(command, args, options); + + return { + success: status === 0, + }; + } catch (e) { + console.error(e); + return { success: false }; + } +} diff --git a/packages/util/tsconfig.json b/packages/util/tsconfig.json new file mode 100644 index 0000000..37deb27 --- /dev/null +++ b/packages/util/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "module": "commonjs" + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/packages/util/tsconfig.lib.json b/packages/util/tsconfig.lib.json new file mode 100644 index 0000000..b6018ca --- /dev/null +++ b/packages/util/tsconfig.lib.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "../../dist/out-tsc", + "declaration": true, + "types": ["node"] + }, + "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"], + "include": ["src/**/*.ts"] +} diff --git a/packages/util/tsconfig.spec.json b/packages/util/tsconfig.spec.json new file mode 100644 index 0000000..ceb45ea --- /dev/null +++ b/packages/util/tsconfig.spec.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"] +} diff --git a/tsconfig.base.json b/tsconfig.base.json index 09095b2..176087f 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -17,7 +17,8 @@ "baseUrl": ".", "paths": { "@ziacik/azure-func": ["packages/azure-func/src/index.ts"], - "@ziacik/upgrade-verify": ["packages/upgrade-verify/src/index.ts"] + "@ziacik/upgrade-verify": ["packages/upgrade-verify/src/index.ts"], + "@ziacik/util": ["packages/util/src/index.ts"] }, "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true,