Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,18 @@ const tmpToolkitHelpers = configureProject(
parent: repo,
name: '@aws-cdk/tmp-toolkit-helpers',
description: 'A temporary package to hold code shared between aws-cdk and @aws-cdk/toolkit-lib',
deps: [],
devDeps: [
cdkBuildTools,
'@types/archiver',
'@types/glob',
'@types/semver',
'fast-check',
],
deps: [
'archiver',
'glob',
'semver',
'yaml@^1',
],
tsconfig: {
compilerOptions: {
Expand All @@ -708,6 +717,7 @@ tmpToolkitHelpers.package.addField('exports', {
'.': './lib/index.js',
'./package.json': './package.json',
'./api': './lib/api/index.js',
'./util': './lib/util/index.js',
});

//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1245,6 +1255,8 @@ toolkitLib.postCompileTask.exec('node build-tools/bundle.mjs');
// Smoke test built JS files
toolkitLib.postCompileTask.exec('node ./lib/index.js >/dev/null 2>/dev/null </dev/null');
toolkitLib.postCompileTask.exec('node ./lib/api/aws-cdk.js >/dev/null 2>/dev/null </dev/null');
toolkitLib.postCompileTask.exec('node ./lib/api/shared-public.js >/dev/null 2>/dev/null </dev/null');
toolkitLib.postCompileTask.exec('node ./lib/private/util.js >/dev/null 2>/dev/null </dev/null');

// Do include all .ts files inside init-templates
toolkitLib.npmignore?.addPatterns(
Expand Down
33 changes: 33 additions & 0 deletions packages/@aws-cdk/tmp-toolkit-helpers/.projen/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/@aws-cdk/tmp-toolkit-helpers/.projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion packages/@aws-cdk/tmp-toolkit-helpers/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/@aws-cdk/tmp-toolkit-helpers/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './api';
export * from './util';
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import { ToolkitError } from '../toolkit/error';

/**
* Return a location that will be used as the CDK home directory.
Expand Down Expand Up @@ -35,31 +34,3 @@ export function cdkHomeDir() {
export function cdkCacheDir() {
return path.join(cdkHomeDir(), 'cache');
}

/**
* From the current file, find the directory that contains the CLI's package.json
*
* Can't use `__dirname` in production code, as the CLI will get bundled as it's
* released and `__dirname` will refer to a different location in the `.ts` form
* as it will in the final executing form.
*/
export function rootDir(): string;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stays in the cli package

export function rootDir(fail: true): string;
export function rootDir(fail: false): string | undefined;
export function rootDir(fail?: boolean) {
function _rootDir(dirname: string): string | undefined {
const manifestPath = path.join(dirname, 'package.json');
if (fs.existsSync(manifestPath)) {
return dirname;
}
if (path.dirname(dirname) === dirname) {
if (fail ?? true) {
throw new ToolkitError('Unable to find package manifest');
}
return undefined;
}
return _rootDir(path.dirname(dirname));
}

return _rootDir(__dirname);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ export * from './bool';
export * from './bytes';
export * from './cloudformation';
export * from './content-hash';
export * from './directories';
export * from './format-error';
export * from './json';
export * from './objects';
export * from './parallel';
export * from './serialize';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isArray, isObject, Obj } from './types';
import { ToolkitError } from '../toolkit/error';
import { ToolkitError } from '../api/toolkit-error';

/**
* Return a new object by adding missing keys into another object
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as fs from 'fs-extra';
import * as fs from 'fs/promises';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fs-extra wasn't needed at all here.

import { formatBytes } from './bytes';
import * as yaml_cfn from './yaml-cfn';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export type Branded<T, B> = T & Brand<B>;
* values which are branded by construction (really just an elaborate
* way to write 'as').
*/
/* c8 ignore next 3 */
export function createBranded<A extends Branded<any, any>>(value: TypeUnderlyingBrand<A>): A {
return value as A;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as semver from 'semver';
import { ToolkitError } from '../toolkit/error';
import { ToolkitError } from '../api/toolkit-error';

// bracket - https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm#MAVEN401
// pep - https://www.python.org/dev/peps/pep-0440/#version-specifiers
Expand Down
3 changes: 3 additions & 0 deletions packages/@aws-cdk/tmp-toolkit-helpers/test/_helpers/sleep.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export async function sleep(ms: number) {
return new Promise((ok) => setTimeout(ok, ms));
}
Loading