Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/clear-amplify-dev-server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@aws-blocks/create-blocks-app': patch
---

Include the local dev-server script when adding AWS Blocks to an Amplify Gen 2 project.
5 changes: 5 additions & 0 deletions packages/create-blocks-app/src/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@
const result = run(['-y', '--skip-install'], tmpDir);
assert.strictEqual(result.exitCode, 0);
assert.match(result.stdout, /Detected Amplify Gen 2 project/);
const packageJson = JSON.parse(readFileSync(join(tmpDir, 'package.json'), 'utf-8'));
const serverPath = join(tmpDir, 'aws-blocks', 'scripts', 'server.ts');
assert.strictEqual(packageJson.scripts['blocks:dev'], 'tsx watch aws-blocks/scripts/server.ts');
assert.ok(existsSync(serverPath));
assert.match(readFileSync(serverPath, 'utf-8'), /startDevServer/);
} finally {
rmSync(tmpDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
}
Expand Down Expand Up @@ -259,7 +264,7 @@
const suffix = parts.pop();
const namepart = parts.join('-');
assert.ok(namepart.length <= 16, `name portion "${namepart}" should be at most 16 chars`);
assert.strictEqual(suffix!.length, 6, 'random suffix should be 6 chars');

Check warning on line 267 in packages/create-blocks-app/src/cli.test.ts

View workflow job for this annotation

GitHub Actions / Build, Unit Tests, E2E Local

lint/style/noNonNullAssertion

Forbidden non-null assertion.
assert.match(config.stackId, /^[a-z][a-z0-9-]*$/i, 'stackId must be CDK/CFN-safe');
} finally {
rmSync(tmpDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
Expand Down Expand Up @@ -288,7 +293,7 @@
const config = JSON.parse(readFileSync(join(tmpDir, '.blocks', 'config.json'), 'utf-8'));
assert.ok(config.stackId, '.blocks/config.json should have a stackId');
assert.match(config.stackId, /^[a-z][a-z0-9-]*$/i, 'stackId must be CDK/CFN-safe');
assert.strictEqual(config.stackId.split('-').pop()!.length, 6, 'suffix should be 6 chars');

Check warning on line 296 in packages/create-blocks-app/src/cli.test.ts

View workflow job for this annotation

GitHub Actions / Build, Unit Tests, E2E Local

lint/style/noNonNullAssertion

Forbidden non-null assertion.
} finally {
rmSync(tmpDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
}
Expand Down Expand Up @@ -333,7 +338,7 @@
assert.strictEqual(result.exitCode, 0);
assert.match(result.stdout, /Blocks app created/);
assert.doesNotMatch(result.stdout, /Installing dependencies/);
assert.match(result.stdout, /\n npm install\n/);

Check warning on line 341 in packages/create-blocks-app/src/cli.test.ts

View workflow job for this annotation

GitHub Actions / Build, Unit Tests, E2E Local

lint/complexity/noAdjacentSpacesInRegex

This regular expression contains unclear uses of consecutive spaces.
assert.strictEqual(existsSync(join(targetDir, 'node_modules')), false);
} finally {
rmSync(tmpDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { startDevServer } from '@aws-blocks/blocks/scripts';

const __dirname = dirname(fileURLToPath(import.meta.url));

startDevServer({
backendPath: join(__dirname, '..', 'index.ts'),
port: 3001,
});
Loading