Boy Reading Story Book
Draft

Make All Read Button

boy and girl xxxx videos download the best free 4k stock video footage

:
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Porduct Launch Icon Make All Read Button

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 83 additions & 5 deletions Story Post For Instagram
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@ const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });

function transformCode(code: string, projectName?: string): string {
const sourceFile = ts.createSourceFile('test.ts', code, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
let transformed = AmplifyHelperTransformer.transform(sourceFile, projectName);
let { sourceFile: transformed } = AmplifyHelperTransformer.transform(sourceFile, projectName);
transformed = AmplifyHelperTransformer.addBranchNameVariable(transformed, projectName);
return printer.printFile(transformed);
}

function transformOnly(code: string, projectName?: string): string {
const sourceFile = ts.createSourceFile('test.ts', code, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
const transformed = AmplifyHelperTransformer.transform(sourceFile, projectName);
const { sourceFile: transformed } = AmplifyHelperTransformer.transform(sourceFile, projectName);
return printer.printFile(transformed);
}

function transformRaw(code: string, projectName?: string): { output: string; addedBackendParam: boolean } {
const sourceFile = ts.createSourceFile('test.ts', code, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
const { sourceFile: transformed, addedBackendParam } = AmplifyHelperTransformer.transform(sourceFile, projectName);
return { output: printer.printFile(transformed), addedBackendParam };
}

describe('AmplifyHelperTransformer', () => {
describe('import removal', () => {
it('removes amplify-dependent-resources-ref imports', () => {
Expand Down Expand Up @@ -183,20 +189,22 @@ class MyStack extends cdk.Stack {
const dependencies = AmplifyHelpers.addResourceDependency(this, []);
const poolId = cdk.Fn.ref(dependencies.auth.myAuth.UserPoolId);
`;
const output = transformOnly(code);
const { output, addedBackendParam } = transformRaw(code);

expect(output).not.toContain('addResourceDependency');
expect(output).toContain('backend.auth.resources.userPool.userPoolId');
expect(addedBackendParam).toBe(true);
});

it('transforms function dependency access with resource name', () => {
const code = `
const deps = AmplifyHelpers.addResourceDependency(this, []);
const arn = cdk.Fn.ref(deps.function.myFunc.Arn);
`;
const output = transformOnly(code);
const { output, addedBackendParam } = transformRaw(code);

expect(output).toContain('backend.functions.myFunc.resources.lambda.functionArn');
expect(addedBackendParam).toBe(true);
});

it('adds backend parameter to constructor when dependencies exist', () => {
Expand All @@ -208,9 +216,79 @@ class MyStack extends cdk.Stack {
}
}
`;
const output = transformOnly(code);
const { output, addedBackendParam } = transformRaw(code);

expect(output).toContain('backend: Backend');
expect(addedBackendParam).toBe(true);
});

it('returns addedBackendParam false when no dependencies exist', () => {
const code = `
class MyStack extends cdk.Stack {
constructor(scope: any, id: string) {
super(scope, id);
}
}
`;
const { addedBackendParam } = transformRaw(code);

expect(addedBackendParam).toBe(false);
});
});

describe('bare addResourceDependency named-import (customer migrationgen2 pattern)', () => {
// Customer Gen1 cdk-stack.ts imports addResourceDependency as a bare named import
// and assigns it to a typed `dependencies` variable. Detection must recognize the
// bare Identifier call (not just PropertyAccess) so refs get rewritten to backend.*
const BARE_IMPORT_CODE = `
import { type AmplifyResourceProps, addResourceDependency } from '@aws-amplify/cli-extensibility-helper';
import { AmplifyDependentResourcesAttributes } from '../../types/amplify-dependent-resources-ref';

export class cdkStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props: AmplifyResourceProps) {
super(scope, id, props);
const dependencies: AmplifyDependentResourcesAttributes = addResourceDependency(this, props, 'myCustom', [
{ category: 'function', resourceName: 'myFunc' },
{ category: 'auth', resourceName: 'myAuth' },
]);
const fnName = cdk.Fn.ref(dependencies.function.myFunc.Name);
const poolArn = cdk.Fn.ref(dependencies.auth.myAuth.UserPoolArn);
}
}
`;

it('detects the bare addResourceDependency call and sets addedBackendParam', () => {
const { addedBackendParam } = transformRaw(BARE_IMPORT_CODE);
expect(addedBackendParam).toBe(true);
});

it('adds the backend constructor parameter', () => {
const { output } = transformRaw(BARE_IMPORT_CODE);
expect(output).toContain('backend: Backend');
});

it('rewrites dependencies.* references to backend.* and removes the call', () => {
const { output } = transformRaw(BARE_IMPORT_CODE);

expect(output).toContain('backend.functions.myFunc.resources.lambda.functionName');
expect(output).toContain('backend.auth.resources.userPool.userPoolArn');
expect(output).not.toContain('addResourceDependency');
expect(output).not.toContain('dependencies.');
expect(output).not.toContain('Fn.ref');
expect(output).not.toContain('AmplifyDependentResourcesAttributes');
});

it('detects a bare addResourceDependency even without a type annotation', () => {
const code = `
import { addResourceDependency } from '@aws-amplify/cli-extensibility-helper';
const dependencies = addResourceDependency(this, props, 'myCustom', []);
const fnName = cdk.Fn.ref(dependencies.function.myFunc.Name);
`;
const { output, addedBackendParam } = transformRaw(code);

expect(addedBackendParam).toBe(true);
expect(output).toContain('backend.functions.myFunc.resources.lambda.functionName');
expect(output).not.toContain('addResourceDependency');
});
});

Expand Down
206 changes: 206 additions & 0 deletions How To Post On Blogger
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
import { CustomResourceGenerator } from '../../../../../../commands/gen2-migration/generate/amplify/custom-resources/custom.generator';
import { BackendGenerator } from '../../../../../../commands/gen2-migration/generate/amplify/backend.generator';
import { RootPackageJsonGenerator } from '../../../../../../commands/gen2-migration/generate/package.json.generator';
import { SpinningLogger } from '../../../../../../commands/gen2-migration/_common/spinning-logger';
import { Gen1App } from '../../../../../../commands/gen2-migration/_common/gen1-app';
import { DEFAULT_STATEFUL_RESOURCES } from '../../../../../../commands/gen2-migration/_common/resource-types';

jest.unmock('fs-extra');

jest.mock('@aws-amplify/amplify-cli-core', () => {
const actual = jest.requireActual('@aws-amplify/amplify-cli-core');
return {
...actual,
JSONUtilities: {
...actual.JSONUtilities,
readJson: jest.fn().mockImplementation((filePath: string, opts?: unknown) => {
if (typeof filePath === 'string' && filePath.endsWith('package.json')) {
return { dependencies: {}, devDependencies: {} };
}
if (typeof filePath === 'string' && filePath.endsWith('project-config.json')) {
return { projectName: 'testProject' };
}
return actual.JSONUtilities.readJson(filePath, opts);
}),
},
};
});

const mockMkdir = jest.fn().mockResolvedValue(undefined);
const mockWriteFile = jest.fn().mockResolvedValue(undefined);
const mockCp = jest.fn().mockResolvedValue(undefined);
const mockRm = jest.fn().mockResolvedValue(undefined);
const mockReadFile = jest.fn();
const mockReaddir = jest.fn().mockResolvedValue([]);
const mockRename = jest.fn().mockResolvedValue(undefined);
jest.mock('node:fs/promises', () => ({
mkdir: (...args: unknown[]) => mockMkdir(...args),
writeFile: (...args: unknown[]) => mockWriteFile(...args),
cp: (...args: unknown[]) => mockCp(...args),
rm: (...args: unknown[]) => mockRm(...args),
readFile: (...args: unknown[]) => mockReadFile(...args),
readdir: (...args: unknown[]) => mockReaddir(...args),
rename: (...args: unknown[]) => mockRename(...args),
}));

const CDK_STACK_WITH_DEPS = `
import * as cdk from 'aws-cdk-lib';
import * as AmplifyHelpers from '@aws-amplify/cli-extensibility-helper';

export class cdkStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const dependencies = AmplifyHelpers.addResourceDependency(this, props, 'myCustom', [
{ category: 'auth', resourceName: 'myAuth' }
]);
const poolId = cdk.Fn.ref(dependencies.auth.myAuth.UserPoolId);
}
}
`;

// Customer migrationgen2 pattern: bare `addResourceDependency` named import assigned
// to a typed `dependencies` variable. Previously undetected -> TS2663 dependencies undefined.
const CDK_STACK_BARE_IMPORT_DEPS = `
import * as cdk from 'aws-cdk-lib';
import { type AmplifyResourceProps, addResourceDependency } from '@aws-amplify/cli-extensibility-helper';
import { AmplifyDependentResourcesAttributes } from '../../types/amplify-dependent-resources-ref';

export class cdkStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props: AmplifyResourceProps) {
super(scope, id, props);
const dependencies: AmplifyDependentResourcesAttributes = addResourceDependency(this, props, 'myCustom', [
{ category: 'function', resourceName: 'myFunc' },
{ category: 'auth', resourceName: 'myAuth' }
]);
const fnName = cdk.Fn.ref(dependencies.function.myFunc.Name);
const poolArn = cdk.Fn.ref(dependencies.auth.myAuth.UserPoolArn);
}
}
`;

const CDK_STACK_NO_DEPS = `
import * as cdk from 'aws-cdk-lib';

export class cdkStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
}
}
`;

/**
* Verifies that the constructor parameter count in construct.ts always matches
* the argument count in the `new <Class>(...)` call in resource.ts.
*/
describe('CustomResourceGenerator dependency consistency', () => {
const outputDir = '/fake/output';
const logger = new SpinningLogger('test');
const gen1App = { statefulResourceTypes: [...Array.from(DEFAULT_STATEFUL_RESOURCES)] } as unknown as Gen1App;

beforeEach(() => {
jest.clearAllMocks();
});

it('construct.ts ctor params == resource.ts new call args when resource has dependencies', async () => {
mockReadFile.mockResolvedValue(CDK_STACK_WITH_DEPS);

const backendGenerator = new BackendGenerator(outputDir, logger);
const packageJsonGenerator = new RootPackageJsonGenerator(outputDir);
const generator = new CustomResourceGenerator(gen1App, backendGenerator, packageJsonGenerator, outputDir, 'myCustom', logger);
const ops = await generator.plan();
await ops[0].execute();

// Find the construct content (written to cdk-stack.ts before rename)
const constructCall = mockWriteFile.mock.calls.find((c: unknown[]) => (c[0] as string).endsWith('cdk-stack.ts'));
expect(constructCall).toBeDefined();
const constructContent = constructCall![1] as string;

// Find the resource.ts content
const resourceCall = mockWriteFile.mock.calls.find((c: unknown[]) => (c[0] as string).endsWith('resource.ts'));
expect(resourceCall).toBeDefined();
const resourceContent = resourceCall![1] as string;

// Count constructor params
const ctorMatch = constructContent.match(/constructor\(([\s\S]*?)\)\s*\{/);
expect(ctorMatch).toBeDefined();
const ctorParams = ctorMatch![1].split(',').filter((p: string) => p.trim()).length;

// Count args in `new MyCustom(...)` — handle nested parens like backend.createStack('...')
const newCallMatch = resourceContent.match(/new MyCustom\(([\s\S]*?)\);/);
expect(newCallMatch).toBeDefined();
const newCallArgs = newCallMatch![1].split(/,(?![^(]*\))/).filter((a: string) => a.trim()).length;

expect(ctorParams).toBe(3); // scope, id, backend
expect(newCallArgs).toBe(ctorParams);
});

it('rewrites bare addResourceDependency refs to backend.* and adds backend param (customer pattern)', async () => {
mockReadFile.mockResolvedValue(CDK_STACK_BARE_IMPORT_DEPS);

const backendGenerator = new BackendGenerator(outputDir, logger);
const packageJsonGenerator = new RootPackageJsonGenerator(outputDir);
const generator = new CustomResourceGenerator(gen1App, backendGenerator, packageJsonGenerator, outputDir, 'myCustom', logger);
const ops = await generator.plan();
await ops[0].execute();

const constructCall = mockWriteFile.mock.calls.find((c: unknown[]) => (c[0] as string).endsWith('cdk-stack.ts'));
expect(constructCall).toBeDefined();
const constructContent = constructCall![1] as string;

const resourceCall = mockWriteFile.mock.calls.find((c: unknown[]) => (c[0] as string).endsWith('resource.ts'));
expect(resourceCall).toBeDefined();
const resourceContent = resourceCall![1] as string;

// backend constructor param emitted and dependency refs rewritten to backend.*
expect(constructContent).toContain('backend: Backend');
expect(constructContent).toContain('backend.functions.myFunc.resources.lambda.functionName');
expect(constructContent).toContain('backend.auth.resources.userPool.userPoolArn');

// No leftover Gen1 dependency artifacts that would cause TS2663
expect(constructContent).not.toContain('addResourceDependency');
expect(constructContent).not.toContain('dependencies.');
expect(constructContent).not.toContain('Fn.ref');
expect(constructContent).not.toContain('AmplifyDependentResourcesAttributes');

// ctor params and resource.ts new call args stay consistent (scope, id, backend)
const ctorMatch = constructContent.match(/constructor\(([\s\S]*?)\)\s*\{/);
expect(ctorMatch).toBeDefined();
const ctorParams = ctorMatch![1].split(',').filter((p: string) => p.trim()).length;

const newCallMatch = resourceContent.match(/new MyCustom\(([\s\S]*?)\);/);
expect(newCallMatch).toBeDefined();
const newCallArgs = newCallMatch![1].split(/,(?![^(]*\))/).filter((a: string) => a.trim()).length;

expect(ctorParams).toBe(3); // scope, id, backend
expect(newCallArgs).toBe(ctorParams);
});

it('construct.ts ctor params == resource.ts new call args when no dependencies', async () => {
mockReadFile.mockResolvedValue(CDK_STACK_NO_DEPS);

const backendGenerator = new BackendGenerator(outputDir, logger);
const packageJsonGenerator = new RootPackageJsonGenerator(outputDir);
const generator = new CustomResourceGenerator(gen1App, backendGenerator, packageJsonGenerator, outputDir, 'noDep', logger);
const ops = await generator.plan();
await ops[0].execute();

const constructCall = mockWriteFile.mock.calls.find((c: unknown[]) => (c[0] as string).endsWith('cdk-stack.ts'));
expect(constructCall).toBeDefined();
const constructContent = constructCall![1] as string;

const resourceCall = mockWriteFile.mock.calls.find((c: unknown[]) => (c[0] as string).endsWith('resource.ts'));
expect(resourceCall).toBeDefined();
const resourceContent = resourceCall![1] as string;

const ctorMatch = constructContent.match(/constructor\(([\s\S]*?)\)\s*\{/);
expect(ctorMatch).toBeDefined();
const ctorParams = ctorMatch![1].split(',').filter((p: string) => p.trim()).length;

const newCallMatch = resourceContent.match(/new NoDep\(([\s\S]*?)\);/);
expect(newCallMatch).toBeDefined();
const newCallArgs = newCallMatch![1].split(/,(?![^(]*\))/).filter((a: string) => a.trim()).length;

expect(ctorParams).toBe(2); // scope, id
expect(newCallArgs).toBe(ctorParams);
});
});
20 changes: 15 additions & 5 deletions Business Cards For 9.99
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class AmplifyHelperTransformer {
/**
* Transforms Gen1 AmplifyHelpers patterns to Gen2 equivalents via AST rewriting.
*/
public static transform(sourceFile: ts.SourceFile, projectName?: string): ts.SourceFile {
public static transform(sourceFile: ts.SourceFile, projectName?: string): { sourceFile: ts.SourceFile; addedBackendParam: boolean } {
// Track variable names that hold AmplifyHelpers.getProjectInfo() result
const projectInfoVariables = new Set<string>();
// Track parameter names with AmplifyResourceProps type
Expand Down Expand Up @@ -146,11 +146,14 @@ export class AmplifyHelperTransformer {
return undefined;
}

// Remove AmplifyHelpers.addResourceDependency variable statements
// Remove addResourceDependency variable statements. Detect both the
// property-access form (`AmplifyHelpers.addResourceDependency(...)`) and the
// bare named-import form (`addResourceDependency(...)`).
if (declaration && declaration.initializer && ts.isCallExpression(declaration.initializer)) {
const callExpr = declaration.initializer;
const isAddResourceDependency =
ts.isPropertyAccessExpression(callExpr.expression) && callExpr.expression.name.text === 'addResourceDependency';
(ts.isPropertyAccessExpression(callExpr.expression) && callExpr.expression.name.text === 'addResourceDependency') ||
(ts.isIdentifier(callExpr.expression) && callExpr.expression.text === 'addResourceDependency');

if (isAddResourceDependency) {
if (ts.isIdentifier(declaration.name)) {
Expand All @@ -177,10 +180,17 @@ export class AmplifyHelperTransformer {
}
}

// Remove variable declarations with AmplifyDependentResourcesAttributes type annotation
// Remove variable declarations with AmplifyDependentResourcesAttributes type annotation.
// Before deleting, register the declared variable so that downstream
// `dependencies.*` references (and Fn.ref(dependencies.*)) get rewritten to backend.*
// and the backend constructor param/arg are emitted.
if (declaration && declaration.type && ts.isTypeReferenceNode(declaration.type)) {
const typeName = declaration.type.typeName;
if (ts.isIdentifier(typeName) && typeName.text === 'AmplifyDependentResourcesAttributes') {
if (ts.isIdentifier(declaration.name)) {
dependencyVariables.add(declaration.name.text);
}
hasDependencies = true;
return undefined;
}
}
Expand Down Expand Up @@ -363,7 +373,7 @@ export class AmplifyHelperTransformer {
};

const result = ts.transform(sourceFile, [transformer]);
return result.transformed[0] as ts.SourceFile;
return { sourceFile: result.transformed[0] as ts.SourceFile, addedBackendParam: hasDependencies };
}

/**
Expand Down
Loading
Loading