create-ampless 0.2.0-alpha.3 → 0.2.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,17 @@
1
+ import { fileURLToPath } from 'node:url'
2
+ import { dirname, resolve } from 'node:path'
1
3
  import { a, defineData, type ClientSchema } from '@aws-amplify/backend'
2
4
  import { amplessSchemaModels, defaultAuthorizationModes } from '@ampless/backend'
3
5
 
6
+ // AppSync's `a.handler.custom({ entry })` paths are resolved by CDK
7
+ // relative to the file that called `a.handler.custom`. When the call
8
+ // originates inside `@ampless/backend` (via amplessSchemaModels), the
9
+ // CDK synth tries to resolve `./list-published-posts.js` relative to
10
+ // `node_modules/@ampless/backend/dist/index.js` and fails with
11
+ // `UnresolvedEntryPathError`. Anchor the resolver paths at THIS file's
12
+ // directory so the result is unambiguous.
13
+ const __dirname = dirname(fileURLToPath(import.meta.url))
14
+
4
15
  // Ampless's built-in models (Post / Page / Media / Taxonomy / PostTag /
5
16
  // KvStore) plus the three public-read custom queries
6
17
  // (listPublishedPosts / getPublishedPost / listPostsByTag).
@@ -8,19 +19,20 @@ import { amplessSchemaModels, defaultAuthorizationModes } from '@ampless/backend
8
19
  // Add project-specific models alongside the spread:
9
20
  //
10
21
  // const schema = a.schema({
11
- // ...amplessSchemaModels(a),
22
+ // ...amplessSchemaModels(a, { resolverPaths }),
12
23
  // MyCustomModel: a
13
24
  // .model({ siteId: a.string().required(), foo: a.string() })
14
25
  // .identifier(['siteId', 'foo'])
15
26
  // .authorization((allow) => [allow.groups(['ampless-admin'])]),
16
27
  // })
17
- //
18
- // The three AppSync JS resolvers (`*.js` in this directory) stay
19
- // user-owned — AppSync resolves `entry: './...'` paths at synth time
20
- // relative to this file. If you relocate them, pass new paths via
21
- // `amplessSchemaModels(a, { resolverPaths: { ... } })`.
28
+ const resolverPaths = {
29
+ listPublishedPosts: resolve(__dirname, 'list-published-posts.js'),
30
+ getPublishedPost: resolve(__dirname, 'get-published-post.js'),
31
+ listPostsByTag: resolve(__dirname, 'list-posts-by-tag.js'),
32
+ }
33
+
22
34
  const schema = a.schema({
23
- ...amplessSchemaModels(a),
35
+ ...amplessSchemaModels(a, { resolverPaths }),
24
36
  })
25
37
 
26
38
  export type Schema = ClientSchema<typeof schema>
@@ -0,0 +1,18 @@
1
+ version: 1
2
+ frontend:
3
+ phases:
4
+ preBuild:
5
+ commands:
6
+ - npm install
7
+ build:
8
+ commands:
9
+ - npx ampx pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID
10
+ - npm run build
11
+ artifacts:
12
+ baseDirectory: .next
13
+ files:
14
+ - '**/*'
15
+ cache:
16
+ paths:
17
+ - node_modules/**/*
18
+ - .next/cache/**/*
@@ -1,9 +1,20 @@
1
- // Back-compat shim. The Amplify SDK is now configured by the admin's
2
- // `<AdminProviders>` bootstrap (mounted by the layout factory in
3
- // `@ampless/admin/pages`), so most call sites no longer need to call
4
- // `configureAmplify()` themselves. Kept as a no-op so any lingering
5
- // `import '@/lib/amplify'` side-effect imports stay safe.
1
+ // Client-side Amplify SDK setup. Imported as a side-effect from
2
+ // `app/providers.tsx` so it runs on every page load (public + admin +
3
+ // login). `<AdminProviders>` (mounted by the admin layout factory)
4
+ // also performs this configuration, but it only runs for routes under
5
+ // the (admin) group; `/login` is a top-level route outside that group
6
+ // and would otherwise hit "Auth UserPool not configured" because no
7
+ // AdminProviders has bootstrapped the SDK yet.
8
+ //
9
+ // `Amplify.configure` is idempotent — calling it once at the root and
10
+ // again inside AdminProviders is harmless.
11
+
12
+ import { Amplify } from 'aws-amplify'
13
+ import outputs from '../amplify_outputs.json'
14
+
15
+ Amplify.configure(outputs, { ssr: true })
6
16
 
7
17
  export function configureAmplify() {
8
- // intentionally empty admin bootstrap handles this
18
+ // module-level side effect above already ran; keep this as a no-op
19
+ // for callers that still import it as a function for back-compat.
9
20
  }
@@ -24,7 +24,7 @@
24
24
  "@ampless/plugin-rss": "^0.2.0-alpha.1",
25
25
  "@ampless/plugin-seo": "^0.2.0-alpha.1",
26
26
  "@ampless/plugin-webhook": "^0.2.0-alpha.1",
27
- "@ampless/admin": "^0.2.0-alpha.2",
27
+ "@ampless/admin": "^0.2.0-alpha.5",
28
28
  "@ampless/backend": "^0.2.0-alpha.1",
29
29
  "@ampless/runtime": "^0.2.0-alpha.2",
30
30
  "@digital-go-jp/tailwind-theme-plugin": "^0.3.4",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ampless",
3
- "version": "0.2.0-alpha.3",
3
+ "version": "0.2.0-alpha.6",
4
4
  "description": "Create a new ampless project",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -23,6 +23,7 @@
23
23
  "bugs": "https://github.com/heavymoons/ampless/issues",
24
24
  "dependencies": {
25
25
  "@clack/prompts": "^1.4.0",
26
+ "execa": "^9.6.1",
26
27
  "picocolors": "^1.1.1"
27
28
  },
28
29
  "keywords": [