@aurostack/stacks 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +209 -0
- package/cli/src/extract.mjs +165 -0
- package/cli/src/fsx.mjs +197 -0
- package/cli/src/generate.mjs +235 -0
- package/cli/src/hooks.mjs +55 -0
- package/cli/src/manifest.mjs +163 -0
- package/cli/src/strip.mjs +208 -0
- package/cli/src/tokens.mjs +102 -0
- package/cli/stack.mjs +672 -0
- package/package.json +37 -0
- package/templates/nest-api/files/.bin/db.ts +123 -0
- package/templates/nest-api/files/.bin/dc.ts +74 -0
- package/templates/nest-api/files/.bin/helpers.ts +49 -0
- package/templates/nest-api/files/.bin/secrets.ts +68 -0
- package/templates/nest-api/files/.bin/start.ts +47 -0
- package/templates/nest-api/files/.dockerignore +7 -0
- package/templates/nest-api/files/.env.example +91 -0
- package/templates/nest-api/files/.env.test.example +75 -0
- package/templates/nest-api/files/.forgejo/workflows/build-and-push.yml +41 -0
- package/templates/nest-api/files/.forgejo/workflows/test-e2e.yml +83 -0
- package/templates/nest-api/files/.forgejo/workflows/test.yml +53 -0
- package/templates/nest-api/files/.npmrc.example +1 -0
- package/templates/nest-api/files/.nvmrc +1 -0
- package/templates/nest-api/files/.prettierrc +8 -0
- package/templates/nest-api/files/.swcrc +15 -0
- package/templates/nest-api/files/.watchmanconfig +3 -0
- package/templates/nest-api/files/.yarnrc.yml +1 -0
- package/templates/nest-api/files/Dockerfile +40 -0
- package/templates/nest-api/files/__mocks__/activation-twofa.js +7 -0
- package/templates/nest-api/files/__mocks__/activation.js +7 -0
- package/templates/nest-api/files/__mocks__/forgot-password.js +7 -0
- package/templates/nest-api/files/__mocks__/main-layout.js +7 -0
- package/templates/nest-api/files/__mocks__/password-changed.js +7 -0
- package/templates/nest-api/files/__mocks__/reset-password.js +7 -0
- package/templates/nest-api/files/__mocks__/set-password.js +7 -0
- package/templates/nest-api/files/__mocks__/welcome.js +7 -0
- package/templates/nest-api/files/_gitignore +62 -0
- package/templates/nest-api/files/compose.test.yml +33 -0
- package/templates/nest-api/files/compose.yml +39 -0
- package/templates/nest-api/files/emails/activation-twofa.tsx +58 -0
- package/templates/nest-api/files/emails/activation.tsx +36 -0
- package/templates/nest-api/files/emails/forgot-password.tsx +29 -0
- package/templates/nest-api/files/emails/main-layout.tsx +134 -0
- package/templates/nest-api/files/emails/password-changed.tsx +24 -0
- package/templates/nest-api/files/emails/reset-password.tsx +24 -0
- package/templates/nest-api/files/emails/set-password.tsx +25 -0
- package/templates/nest-api/files/emails/welcome.tsx +39 -0
- package/templates/nest-api/files/eslint.config.mjs +28 -0
- package/templates/nest-api/files/global.d.ts +5 -0
- package/templates/nest-api/files/nest-cli.json +8 -0
- package/templates/nest-api/files/package.json +150 -0
- package/templates/nest-api/files/prisma/schema/auth.prisma +75 -0
- package/templates/nest-api/files/prisma/schema/base.prisma +17 -0
- package/templates/nest-api/files/prisma/schema/enum.prisma +17 -0
- package/templates/nest-api/files/prisma/schema/notification.prisma +14 -0
- package/templates/nest-api/files/prisma.config.ts +13 -0
- package/templates/nest-api/files/public/.gitkeep +0 -0
- package/templates/nest-api/files/seeders/index.ts +27 -0
- package/templates/nest-api/files/seeders/util.ts +88 -0
- package/templates/nest-api/files/src/__tests__/app.controller.spec.ts +29 -0
- package/templates/nest-api/files/src/app.controller.ts +40 -0
- package/templates/nest-api/files/src/app.module.ts +268 -0
- package/templates/nest-api/files/src/app.resolver.ts +32 -0
- package/templates/nest-api/files/src/app.setup.ts +178 -0
- package/templates/nest-api/files/src/common/__tests__/auth.service.spec.ts +31 -0
- package/templates/nest-api/files/src/common/__tests__/cache.service.spec.ts +214 -0
- package/templates/nest-api/files/src/common/__tests__/config.service.spec.ts +56 -0
- package/templates/nest-api/files/src/common/__tests__/generator.service.spec.ts +114 -0
- package/templates/nest-api/files/src/common/__tests__/health.controller.spec.ts +72 -0
- package/templates/nest-api/files/src/common/__tests__/helpers.spec.ts +124 -0
- package/templates/nest-api/files/src/common/__tests__/mail.service.spec.ts +75 -0
- package/templates/nest-api/files/src/common/__tests__/prisma.indicator.spec.ts +39 -0
- package/templates/nest-api/files/src/common/__tests__/prisma.service.spec.ts +15 -0
- package/templates/nest-api/files/src/common/__tests__/records.spec.ts +87 -0
- package/templates/nest-api/files/src/common/__tests__/schemas.spec.ts +142 -0
- package/templates/nest-api/files/src/common/__tests__/throttler-storage.service.spec.ts +80 -0
- package/templates/nest-api/files/src/common/common.module.ts +72 -0
- package/templates/nest-api/files/src/common/constants/index.ts +2 -0
- package/templates/nest-api/files/src/common/constants/options.ts +52 -0
- package/templates/nest-api/files/src/common/constants/pino.ts +24 -0
- package/templates/nest-api/files/src/common/controllers/health.controller.ts +54 -0
- package/templates/nest-api/files/src/common/controllers/index.ts +2 -0
- package/templates/nest-api/files/src/common/controllers/metrics.controller.ts +21 -0
- package/templates/nest-api/files/src/common/decorators/index.ts +2 -0
- package/templates/nest-api/files/src/common/decorators/misc.decorator.ts +49 -0
- package/templates/nest-api/files/src/common/decorators/multi-part.decorator.ts +6 -0
- package/templates/nest-api/files/src/common/dto/filters.dto.ts +25 -0
- package/templates/nest-api/files/src/common/dto/index.ts +1 -0
- package/templates/nest-api/files/src/common/entity/index.ts +2 -0
- package/templates/nest-api/files/src/common/entity/ok.entity.ts +11 -0
- package/templates/nest-api/files/src/common/entity/pagination.entity.ts +24 -0
- package/templates/nest-api/files/src/common/exceptions/index.ts +1 -0
- package/templates/nest-api/files/src/common/exceptions/prisma.exception.ts +57 -0
- package/templates/nest-api/files/src/common/guards/feature-flag.guard.ts +51 -0
- package/templates/nest-api/files/src/common/guards/index.ts +1 -0
- package/templates/nest-api/files/src/common/interceptors/index.ts +1 -0
- package/templates/nest-api/files/src/common/interceptors/metrics.interceptor.ts +37 -0
- package/templates/nest-api/files/src/common/misc/helpers.ts +26 -0
- package/templates/nest-api/files/src/common/misc/index.ts +3 -0
- package/templates/nest-api/files/src/common/misc/origin-builder.ts +56 -0
- package/templates/nest-api/files/src/common/misc/prisma.indicator.ts +24 -0
- package/templates/nest-api/files/src/common/modules/index.ts +3 -0
- package/templates/nest-api/files/src/common/modules/logger.module.ts +104 -0
- package/templates/nest-api/files/src/common/modules/metrics.module.ts +28 -0
- package/templates/nest-api/files/src/common/modules/queue.module.ts +23 -0
- package/templates/nest-api/files/src/common/processors/index.ts +1 -0
- package/templates/nest-api/files/src/common/processors/mail/index.ts +47 -0
- package/templates/nest-api/files/src/common/processors/mail/process.ts +225 -0
- package/templates/nest-api/files/src/common/schemas/fields.ts +76 -0
- package/templates/nest-api/files/src/common/schemas/index.ts +1 -0
- package/templates/nest-api/files/src/common/services/auth-rate-limit.storage.ts +79 -0
- package/templates/nest-api/files/src/common/services/auth.service.ts +16 -0
- package/templates/nest-api/files/src/common/services/cache.service.ts +118 -0
- package/templates/nest-api/files/src/common/services/config.service.ts +388 -0
- package/templates/nest-api/files/src/common/services/feature-flag.service.ts +117 -0
- package/templates/nest-api/files/src/common/services/generator.service.ts +54 -0
- package/templates/nest-api/files/src/common/services/index.ts +10 -0
- package/templates/nest-api/files/src/common/services/logger.service.ts +14 -0
- package/templates/nest-api/files/src/common/services/mail.service.ts +44 -0
- package/templates/nest-api/files/src/common/services/prisma.service.ts +106 -0
- package/templates/nest-api/files/src/common/services/throttler-storage.service.ts +112 -0
- package/templates/nest-api/files/src/common/types/email.ts +55 -0
- package/templates/nest-api/files/src/common/types/index.ts +3 -0
- package/templates/nest-api/files/src/common/types/misc.ts +20 -0
- package/templates/nest-api/files/src/common/types/prisma.ts +18 -0
- package/templates/nest-api/files/src/common/utils/enum.ts +39 -0
- package/templates/nest-api/files/src/common/utils/helpers.ts +139 -0
- package/templates/nest-api/files/src/common/utils/index.ts +5 -0
- package/templates/nest-api/files/src/common/utils/ip.ts +22 -0
- package/templates/nest-api/files/src/common/utils/records.ts +66 -0
- package/templates/nest-api/files/src/common/utils/redis.keys.ts +31 -0
- package/templates/nest-api/files/src/lib/__tests__/access.spec.ts +33 -0
- package/templates/nest-api/files/src/lib/access.ts +114 -0
- package/templates/nest-api/files/src/lib/auth.ts +76 -0
- package/templates/nest-api/files/src/lib/rate-limit.ts +20 -0
- package/templates/nest-api/files/src/main.ts +28 -0
- package/templates/nest-api/files/src/media/__tests__/media.service.spec.ts +60 -0
- package/templates/nest-api/files/src/media/__tests__/s3.service.spec.ts +159 -0
- package/templates/nest-api/files/src/media/entity/file.entity.ts +7 -0
- package/templates/nest-api/files/src/media/entity/index.ts +1 -0
- package/templates/nest-api/files/src/media/media.module.ts +20 -0
- package/templates/nest-api/files/src/media/processors/index.ts +44 -0
- package/templates/nest-api/files/src/media/services/index.ts +2 -0
- package/templates/nest-api/files/src/media/services/media.service.ts +29 -0
- package/templates/nest-api/files/src/media/services/s3.service.ts +168 -0
- package/templates/nest-api/files/src/notifications/controllers/index.ts +1 -0
- package/templates/nest-api/files/src/notifications/controllers/notifications.controller.ts +72 -0
- package/templates/nest-api/files/src/notifications/dto/index.ts +1 -0
- package/templates/nest-api/files/src/notifications/dto/notification.dto.ts +11 -0
- package/templates/nest-api/files/src/notifications/entity/index.ts +1 -0
- package/templates/nest-api/files/src/notifications/entity/notification.entity.ts +37 -0
- package/templates/nest-api/files/src/notifications/notifications.module.ts +11 -0
- package/templates/nest-api/files/src/notifications/services/index.ts +1 -0
- package/templates/nest-api/files/src/notifications/services/notifications.service.ts +98 -0
- package/templates/nest-api/files/src/realtime/__tests__/events.gateway.spec.ts +88 -0
- package/templates/nest-api/files/src/realtime/__tests__/rooms.spec.ts +29 -0
- package/templates/nest-api/files/src/realtime/__tests__/ws-permissions.guard.spec.ts +54 -0
- package/templates/nest-api/files/src/realtime/adapters/redis-io.adapter.ts +57 -0
- package/templates/nest-api/files/src/realtime/constants/index.ts +68 -0
- package/templates/nest-api/files/src/realtime/decorators/index.ts +1 -0
- package/templates/nest-api/files/src/realtime/decorators/ws-permissions.decorator.ts +14 -0
- package/templates/nest-api/files/src/realtime/gateways/events.gateway.ts +187 -0
- package/templates/nest-api/files/src/realtime/guards/index.ts +2 -0
- package/templates/nest-api/files/src/realtime/guards/ws-auth.guard.ts +20 -0
- package/templates/nest-api/files/src/realtime/guards/ws-permissions.guard.ts +35 -0
- package/templates/nest-api/files/src/realtime/misc/session-from-socket.ts +54 -0
- package/templates/nest-api/files/src/realtime/realtime.module.ts +26 -0
- package/templates/nest-api/files/src/realtime/services/presence.service.ts +56 -0
- package/templates/nest-api/files/src/realtime/services/realtime.service.ts +72 -0
- package/templates/nest-api/files/src/users/__tests__/current-user.controller.spec.ts +77 -0
- package/templates/nest-api/files/src/users/__tests__/current-user.service.spec.ts +159 -0
- package/templates/nest-api/files/src/users/__tests__/user.entity.spec.ts +175 -0
- package/templates/nest-api/files/src/users/__tests__/users.controller.spec.ts +89 -0
- package/templates/nest-api/files/src/users/__tests__/users.service.spec.ts +398 -0
- package/templates/nest-api/files/src/users/controllers/current-user.controller.ts +82 -0
- package/templates/nest-api/files/src/users/controllers/index.ts +2 -0
- package/templates/nest-api/files/src/users/controllers/users.controller.ts +40 -0
- package/templates/nest-api/files/src/users/decorators/index.ts +1 -0
- package/templates/nest-api/files/src/users/decorators/permissions.decorator.ts +24 -0
- package/templates/nest-api/files/src/users/dto/avatar.dto.ts +13 -0
- package/templates/nest-api/files/src/users/dto/filters.dto.ts +8 -0
- package/templates/nest-api/files/src/users/dto/index.ts +2 -0
- package/templates/nest-api/files/src/users/entity/index.ts +1 -0
- package/templates/nest-api/files/src/users/entity/user.entity.ts +53 -0
- package/templates/nest-api/files/src/users/services/current-user.service.ts +46 -0
- package/templates/nest-api/files/src/users/services/index.ts +2 -0
- package/templates/nest-api/files/src/users/services/users.service.ts +88 -0
- package/templates/nest-api/files/src/users/users.module.ts +10 -0
- package/templates/nest-api/files/test/app.spec.ts +102 -0
- package/templates/nest-api/files/test/auth.spec.ts +108 -0
- package/templates/nest-api/files/test/current-user.spec.ts +154 -0
- package/templates/nest-api/files/test/factory/app.ts +172 -0
- package/templates/nest-api/files/test/factory/constants.ts +22 -0
- package/templates/nest-api/files/test/factory/dto.ts +27 -0
- package/templates/nest-api/files/test/factory/entity.ts +70 -0
- package/templates/nest-api/files/test/factory/gen.ts +75 -0
- package/templates/nest-api/files/test/factory/util.ts +21 -0
- package/templates/nest-api/files/test/notifications.spec.ts +176 -0
- package/templates/nest-api/files/test/rate-limit.spec.ts +180 -0
- package/templates/nest-api/files/test/setup.ts +1 -0
- package/templates/nest-api/files/test/users.spec.ts +437 -0
- package/templates/nest-api/files/tsconfig.build.json +13 -0
- package/templates/nest-api/files/tsconfig.json +35 -0
- package/templates/nest-api/files/vitest.config.ts +53 -0
- package/templates/nest-api/template.json +452 -0
- package/templates/node-worker/files/.bin/db.ts +123 -0
- package/templates/node-worker/files/.bin/helpers.ts +49 -0
- package/templates/node-worker/files/.bin/secrets.ts +68 -0
- package/templates/node-worker/files/.dockerignore +5 -0
- package/templates/node-worker/files/.env.example +21 -0
- package/templates/node-worker/files/.forgejo/workflows/build-and-push.yml +41 -0
- package/templates/node-worker/files/.nvmrc +1 -0
- package/templates/node-worker/files/.prettierignore +4 -0
- package/templates/node-worker/files/.prettierrc +8 -0
- package/templates/node-worker/files/.yarnrc.yml +5 -0
- package/templates/node-worker/files/Dockerfile +63 -0
- package/templates/node-worker/files/Dockerfile.dev +59 -0
- package/templates/node-worker/files/_gitignore +48 -0
- package/templates/node-worker/files/ecosystem.config.cjs +10 -0
- package/templates/node-worker/files/eslint.config.js +37 -0
- package/templates/node-worker/files/package.json +67 -0
- package/templates/node-worker/files/prisma/_gitignore +1 -0
- package/templates/node-worker/files/prisma/schema/base.prisma +36 -0
- package/templates/node-worker/files/prisma.config.ts +13 -0
- package/templates/node-worker/files/src/config.ts +55 -0
- package/templates/node-worker/files/src/db.ts +118 -0
- package/templates/node-worker/files/src/index.ts +7 -0
- package/templates/node-worker/files/src/logger.ts +45 -0
- package/templates/node-worker/files/src/types.ts +23 -0
- package/templates/node-worker/files/src/utils/browser.ts +16 -0
- package/templates/node-worker/files/src/utils/date.ts +68 -0
- package/templates/node-worker/files/src/utils/helpers.ts +17 -0
- package/templates/node-worker/files/src/utils/number.ts +47 -0
- package/templates/node-worker/files/src/utils/worker.ts +29 -0
- package/templates/node-worker/files/src/workers/constants.ts +6 -0
- package/templates/node-worker/files/src/workers/example/index.ts +27 -0
- package/templates/node-worker/files/src/workers/index.ts +1 -0
- package/templates/node-worker/files/tsconfig.json +30 -0
- package/templates/node-worker/template.json +135 -0
- package/templates/py-worker/files/.dockerignore +176 -0
- package/templates/py-worker/files/.env.example +20 -0
- package/templates/py-worker/files/.forgejo/workflows/build-amd-push.yml +39 -0
- package/templates/py-worker/files/Dockerfile +10 -0
- package/templates/py-worker/files/README.md +3 -0
- package/templates/py-worker/files/_gitignore +176 -0
- package/templates/py-worker/files/config.py +89 -0
- package/templates/py-worker/files/models/decorators.py +42 -0
- package/templates/py-worker/files/models/enums.py +32 -0
- package/templates/py-worker/files/models/mixins.py +61 -0
- package/templates/py-worker/files/requirements.txt +18 -0
- package/templates/py-worker/files/utils/db.py +67 -0
- package/templates/py-worker/files/utils/logger.py +97 -0
- package/templates/py-worker/files/utils/misc.py +45 -0
- package/templates/py-worker/files/utils/worker.py +80 -0
- package/templates/py-worker/files/worker.py +41 -0
- package/templates/py-worker/files/workers/hello/process.py +22 -0
- package/templates/py-worker/template.json +87 -0
- package/templates/react-app/README.md +78 -0
- package/templates/react-app/derive.sh +128 -0
- package/templates/react-app/files/.bin/openapi.js +32 -0
- package/templates/react-app/files/.bin/secrets.js +47 -0
- package/templates/react-app/files/.dockerignore +16 -0
- package/templates/react-app/files/.editorconfig +12 -0
- package/templates/react-app/files/.env.example +34 -0
- package/templates/react-app/files/.forgejo/workflows/build-and-push.yml +55 -0
- package/templates/react-app/files/.forgejo/workflows/ci.yml +39 -0
- package/templates/react-app/files/.husky/pre-commit +1 -0
- package/templates/react-app/files/.nvmrc +1 -0
- package/templates/react-app/files/.prettierignore +6 -0
- package/templates/react-app/files/.prettierrc +9 -0
- package/templates/react-app/files/.yarnrc.yml +2 -0
- package/templates/react-app/files/Dockerfile +52 -0
- package/templates/react-app/files/_gitignore +33 -0
- package/templates/react-app/files/build.sh +53 -0
- package/templates/react-app/files/docker/nginx.conf +134 -0
- package/templates/react-app/files/eslint.config.mjs +75 -0
- package/templates/react-app/files/index.html +62 -0
- package/templates/react-app/files/openapi-ts.config.ts +22 -0
- package/templates/react-app/files/package.json +80 -0
- package/templates/react-app/files/src/app/nav.tsx +32 -0
- package/templates/react-app/files/src/app/providers.tsx +39 -0
- package/templates/react-app/files/src/app/router.tsx +142 -0
- package/templates/react-app/files/src/app/store.ts +20 -0
- package/templates/react-app/files/src/features/auth/components/auth-card.tsx +23 -0
- package/templates/react-app/files/src/features/auth/components/checkbox-field.tsx +32 -0
- package/templates/react-app/files/src/features/auth/components/google-button.tsx +41 -0
- package/templates/react-app/files/src/features/auth/components/or-divider.tsx +9 -0
- package/templates/react-app/files/src/features/auth/components/password-field.tsx +70 -0
- package/templates/react-app/files/src/features/auth/components/submit-button.tsx +16 -0
- package/templates/react-app/files/src/features/auth/lib/auth-actions.ts +68 -0
- package/templates/react-app/files/src/features/auth/lib/password-strength.ts +20 -0
- package/templates/react-app/files/src/features/auth/lib/redirect.ts +6 -0
- package/templates/react-app/files/src/features/auth/lib/schemas.ts +37 -0
- package/templates/react-app/files/src/features/seo/routes.ts +65 -0
- package/templates/react-app/files/src/lib/env.ts +28 -0
- package/templates/react-app/files/src/lib/paths.ts +58 -0
- package/templates/react-app/files/src/main.tsx +19 -0
- package/templates/react-app/files/src/routes/admin/home.tsx +24 -0
- package/templates/react-app/files/src/routes/auth/forgot-password.tsx +93 -0
- package/templates/react-app/files/src/routes/auth/login.tsx +87 -0
- package/templates/react-app/files/src/routes/auth/reset-password.tsx +83 -0
- package/templates/react-app/files/src/routes/auth/signup.tsx +117 -0
- package/templates/react-app/files/src/routes/auth/verified.tsx +31 -0
- package/templates/react-app/files/src/routes/auth/verify-email.tsx +97 -0
- package/templates/react-app/files/src/routes/home.tsx +17 -0
- package/templates/react-app/files/src/routes/legal/privacy.tsx +26 -0
- package/templates/react-app/files/src/routes/legal/terms.tsx +28 -0
- package/templates/react-app/files/src/routes/marketing/home.tsx +18 -0
- package/templates/react-app/files/src/routes/settings.tsx +10 -0
- package/templates/react-app/files/src/shared/api/base-api.ts +24 -0
- package/templates/react-app/files/src/shared/api/base-query.ts +29 -0
- package/templates/react-app/files/src/shared/api/config.ts +21 -0
- package/templates/react-app/files/src/shared/api/index.ts +15 -0
- package/templates/react-app/files/src/shared/api/realtime-events.ts +34 -0
- package/templates/react-app/files/src/shared/api/socket.ts +41 -0
- package/templates/react-app/files/src/shared/api/store.ts +39 -0
- package/templates/react-app/files/src/shared/api/upload-query.ts +115 -0
- package/templates/react-app/files/src/shared/auth/client.ts +27 -0
- package/templates/react-app/files/src/shared/auth/config.ts +28 -0
- package/templates/react-app/files/src/shared/auth/guards.tsx +75 -0
- package/templates/react-app/files/src/shared/auth/hooks.ts +13 -0
- package/templates/react-app/files/src/shared/auth/index.ts +20 -0
- package/templates/react-app/files/src/shared/auth/logout.ts +23 -0
- package/templates/react-app/files/src/shared/auth/provider.tsx +52 -0
- package/templates/react-app/files/src/shared/auth/redirect.ts +65 -0
- package/templates/react-app/files/src/shared/auth/slice.ts +54 -0
- package/templates/react-app/files/src/shared/hooks/index.ts +6 -0
- package/templates/react-app/files/src/shared/layouts/app-shell/app-shell.tsx +225 -0
- package/templates/react-app/files/src/shared/layouts/app-shell/user-menu.tsx +74 -0
- package/templates/react-app/files/src/shared/layouts/auth-layout.tsx +137 -0
- package/templates/react-app/files/src/shared/layouts/error-boundary.tsx +38 -0
- package/templates/react-app/files/src/shared/layouts/index.ts +23 -0
- package/templates/react-app/files/src/shared/layouts/marketing/marketing-layout.tsx +29 -0
- package/templates/react-app/files/src/shared/layouts/marketing/section-heading.tsx +38 -0
- package/templates/react-app/files/src/shared/layouts/marketing/section.tsx +30 -0
- package/templates/react-app/files/src/shared/layouts/states/app-shell-skeleton.tsx +47 -0
- package/templates/react-app/files/src/shared/layouts/states/empty.tsx +22 -0
- package/templates/react-app/files/src/shared/layouts/states/forbidden.tsx +14 -0
- package/templates/react-app/files/src/shared/layouts/states/loading.tsx +11 -0
- package/templates/react-app/files/src/shared/layouts/states/not-found.tsx +21 -0
- package/templates/react-app/files/src/shared/layouts/states/page-skeleton.tsx +39 -0
- package/templates/react-app/files/src/shared/layouts/states/route-fallback.tsx +26 -0
- package/templates/react-app/files/src/shared/layouts/states/state-screen.tsx +22 -0
- package/templates/react-app/files/src/shared/types/README.md +28 -0
- package/templates/react-app/files/src/shared/types/api/index.ts +9 -0
- package/templates/react-app/files/src/shared/types/api/zod.gen.ts +5 -0
- package/templates/react-app/files/src/shared/types/index.ts +4 -0
- package/templates/react-app/files/src/shared/ui/components/brand/logo.tsx +51 -0
- package/templates/react-app/files/src/shared/ui/components/brand/social-icons.tsx +37 -0
- package/templates/react-app/files/src/shared/ui/components/form/form.tsx +120 -0
- package/templates/react-app/files/src/shared/ui/components/ui/alert.tsx +25 -0
- package/templates/react-app/files/src/shared/ui/components/ui/button.tsx +43 -0
- package/templates/react-app/files/src/shared/ui/components/ui/calendar.tsx +78 -0
- package/templates/react-app/files/src/shared/ui/components/ui/card.tsx +44 -0
- package/templates/react-app/files/src/shared/ui/components/ui/checkbox.tsx +16 -0
- package/templates/react-app/files/src/shared/ui/components/ui/date-picker.tsx +76 -0
- package/templates/react-app/files/src/shared/ui/components/ui/input.tsx +22 -0
- package/templates/react-app/files/src/shared/ui/components/ui/label.tsx +19 -0
- package/templates/react-app/files/src/shared/ui/components/ui/modal.tsx +94 -0
- package/templates/react-app/files/src/shared/ui/components/ui/popover.tsx +31 -0
- package/templates/react-app/files/src/shared/ui/components/ui/progress.tsx +33 -0
- package/templates/react-app/files/src/shared/ui/components/ui/search-input.tsx +69 -0
- package/templates/react-app/files/src/shared/ui/components/ui/select.tsx +80 -0
- package/templates/react-app/files/src/shared/ui/components/ui/skeleton.tsx +12 -0
- package/templates/react-app/files/src/shared/ui/components/ui/sonner.tsx +23 -0
- package/templates/react-app/files/src/shared/ui/components/ui/spinner.tsx +8 -0
- package/templates/react-app/files/src/shared/ui/components/ui/textarea.tsx +22 -0
- package/templates/react-app/files/src/shared/ui/index.ts +45 -0
- package/templates/react-app/files/src/shared/ui/lib/utils.ts +7 -0
- package/templates/react-app/files/src/shared/ui/lib/zod-setup.ts +28 -0
- package/templates/react-app/files/src/shared/ui/meta/brand.ts +18 -0
- package/templates/react-app/files/src/shared/ui/meta/meta-context.ts +30 -0
- package/templates/react-app/files/src/shared/ui/meta/meta-provider.tsx +24 -0
- package/templates/react-app/files/src/shared/ui/meta/page-meta.tsx +69 -0
- package/templates/react-app/files/src/shared/ui/meta/use-meta-config.ts +11 -0
- package/templates/react-app/files/src/shared/ui/styles/globals.css +285 -0
- package/templates/react-app/files/src/shared/ui/styles/theme.css +48 -0
- package/templates/react-app/files/src/shared/ui/theme/init-script.ts +23 -0
- package/templates/react-app/files/src/shared/ui/theme/theme-colors.ts +14 -0
- package/templates/react-app/files/src/shared/ui/theme/theme-context.ts +60 -0
- package/templates/react-app/files/src/shared/ui/theme/theme-provider.tsx +101 -0
- package/templates/react-app/files/src/shared/ui/theme/theme-toggle.tsx +40 -0
- package/templates/react-app/files/src/shared/ui/theme/use-theme.ts +11 -0
- package/templates/react-app/files/src/vite-env.d.ts +13 -0
- package/templates/react-app/files/tsconfig.json +26 -0
- package/templates/react-app/files/tsconfig.node.json +25 -0
- package/templates/react-app/files/vite.config.ts +344 -0
- package/templates/react-app/overrides/src/routes/auth/forgot-password.tsx +93 -0
- package/templates/react-app/overrides/src/routes/auth/login.tsx +87 -0
- package/templates/react-app/overrides/src/routes/auth/signup.tsx +117 -0
- package/templates/react-app/overrides/src/routes/auth/verified.tsx +31 -0
- package/templates/react-app/overrides/src/routes/auth/verify-email.tsx +97 -0
- package/templates/react-app/overrides/src/shared/auth/config.ts +28 -0
- package/templates/react-app/overrides/src/shared/auth/guards.tsx +75 -0
- package/templates/react-app/overrides/src/shared/auth/index.ts +20 -0
- package/templates/react-app/overrides/src/shared/auth/redirect.ts +65 -0
- package/templates/react-app/overrides/src/shared/hooks/index.ts +6 -0
- package/templates/react-app/overrides/src/shared/types/README.md +28 -0
- package/templates/react-app/template.json +222 -0
- package/templates/react-monorepo/files/.dockerignore +19 -0
- package/templates/react-monorepo/files/.editorconfig +12 -0
- package/templates/react-monorepo/files/.forgejo/workflows/build-and-push.yml +98 -0
- package/templates/react-monorepo/files/.forgejo/workflows/ci.yml +35 -0
- package/templates/react-monorepo/files/.husky/pre-commit +1 -0
- package/templates/react-monorepo/files/.nvmrc +1 -0
- package/templates/react-monorepo/files/.prettierignore +6 -0
- package/templates/react-monorepo/files/.prettierrc +9 -0
- package/templates/react-monorepo/files/.yarnrc.yml +2 -0
- package/templates/react-monorepo/files/Dockerfile +90 -0
- package/templates/react-monorepo/files/_gitignore +35 -0
- package/templates/react-monorepo/files/apps/admin/.bin/secrets.js +57 -0
- package/templates/react-monorepo/files/apps/admin/.env.example +16 -0
- package/templates/react-monorepo/files/apps/admin/eslint.config.mjs +3 -0
- package/templates/react-monorepo/files/apps/admin/index.html +57 -0
- package/templates/react-monorepo/files/apps/admin/package.json +33 -0
- package/templates/react-monorepo/files/apps/admin/src/App.tsx +3 -0
- package/templates/react-monorepo/files/apps/admin/src/app/nav.tsx +14 -0
- package/templates/react-monorepo/files/apps/admin/src/app/providers.tsx +42 -0
- package/templates/react-monorepo/files/apps/admin/src/app/router.tsx +50 -0
- package/templates/react-monorepo/files/apps/admin/src/app/store.ts +15 -0
- package/templates/react-monorepo/files/apps/admin/src/lib/env.ts +12 -0
- package/templates/react-monorepo/files/apps/admin/src/main.tsx +14 -0
- package/templates/react-monorepo/files/apps/admin/src/routes/home.tsx +17 -0
- package/templates/react-monorepo/files/apps/admin/src/routes/settings.tsx +10 -0
- package/templates/react-monorepo/files/apps/admin/src/vite-env.d.ts +14 -0
- package/templates/react-monorepo/files/apps/admin/tsconfig.json +10 -0
- package/templates/react-monorepo/files/apps/admin/vite.config.ts +13 -0
- package/templates/react-monorepo/files/apps/auth/.bin/secrets.js +57 -0
- package/templates/react-monorepo/files/apps/auth/.env.example +16 -0
- package/templates/react-monorepo/files/apps/auth/eslint.config.mjs +3 -0
- package/templates/react-monorepo/files/apps/auth/index.html +57 -0
- package/templates/react-monorepo/files/apps/auth/package.json +32 -0
- package/templates/react-monorepo/files/apps/auth/src/App.tsx +3 -0
- package/templates/react-monorepo/files/apps/auth/src/app/providers.tsx +42 -0
- package/templates/react-monorepo/files/apps/auth/src/app/router.tsx +19 -0
- package/templates/react-monorepo/files/apps/auth/src/app/store.ts +15 -0
- package/templates/react-monorepo/files/apps/auth/src/components/auth-card.tsx +23 -0
- package/templates/react-monorepo/files/apps/auth/src/components/checkbox-field.tsx +32 -0
- package/templates/react-monorepo/files/apps/auth/src/components/google-button.tsx +41 -0
- package/templates/react-monorepo/files/apps/auth/src/components/or-divider.tsx +9 -0
- package/templates/react-monorepo/files/apps/auth/src/components/password-field.tsx +70 -0
- package/templates/react-monorepo/files/apps/auth/src/components/submit-button.tsx +16 -0
- package/templates/react-monorepo/files/apps/auth/src/lib/auth-actions.ts +68 -0
- package/templates/react-monorepo/files/apps/auth/src/lib/env.ts +8 -0
- package/templates/react-monorepo/files/apps/auth/src/lib/password-strength.ts +20 -0
- package/templates/react-monorepo/files/apps/auth/src/lib/redirect.ts +6 -0
- package/templates/react-monorepo/files/apps/auth/src/lib/schemas.ts +37 -0
- package/templates/react-monorepo/files/apps/auth/src/main.tsx +14 -0
- package/templates/react-monorepo/files/apps/auth/src/routes/forgot-password.tsx +91 -0
- package/templates/react-monorepo/files/apps/auth/src/routes/login.tsx +82 -0
- package/templates/react-monorepo/files/apps/auth/src/routes/reset-password.tsx +83 -0
- package/templates/react-monorepo/files/apps/auth/src/routes/signup.tsx +117 -0
- package/templates/react-monorepo/files/apps/auth/src/routes/verified.tsx +30 -0
- package/templates/react-monorepo/files/apps/auth/src/routes/verify-email.tsx +96 -0
- package/templates/react-monorepo/files/apps/auth/src/vite-env.d.ts +14 -0
- package/templates/react-monorepo/files/apps/auth/tsconfig.json +10 -0
- package/templates/react-monorepo/files/apps/auth/vite.config.ts +13 -0
- package/templates/react-monorepo/files/apps/client/.bin/secrets.js +57 -0
- package/templates/react-monorepo/files/apps/client/.env.example +16 -0
- package/templates/react-monorepo/files/apps/client/eslint.config.mjs +3 -0
- package/templates/react-monorepo/files/apps/client/index.html +57 -0
- package/templates/react-monorepo/files/apps/client/package.json +35 -0
- package/templates/react-monorepo/files/apps/client/src/App.tsx +3 -0
- package/templates/react-monorepo/files/apps/client/src/app/nav.tsx +14 -0
- package/templates/react-monorepo/files/apps/client/src/app/providers.tsx +42 -0
- package/templates/react-monorepo/files/apps/client/src/app/router.tsx +50 -0
- package/templates/react-monorepo/files/apps/client/src/app/store.ts +15 -0
- package/templates/react-monorepo/files/apps/client/src/lib/env.ts +12 -0
- package/templates/react-monorepo/files/apps/client/src/main.tsx +19 -0
- package/templates/react-monorepo/files/apps/client/src/routes/home.tsx +17 -0
- package/templates/react-monorepo/files/apps/client/src/routes/settings.tsx +10 -0
- package/templates/react-monorepo/files/apps/client/src/vite-env.d.ts +15 -0
- package/templates/react-monorepo/files/apps/client/tsconfig.json +10 -0
- package/templates/react-monorepo/files/apps/client/vite.config.ts +120 -0
- package/templates/react-monorepo/files/apps/landing/.bin/secrets.js +57 -0
- package/templates/react-monorepo/files/apps/landing/.env.example +20 -0
- package/templates/react-monorepo/files/apps/landing/eslint.config.mjs +3 -0
- package/templates/react-monorepo/files/apps/landing/index.html +51 -0
- package/templates/react-monorepo/files/apps/landing/package.json +33 -0
- package/templates/react-monorepo/files/apps/landing/src/App.tsx +3 -0
- package/templates/react-monorepo/files/apps/landing/src/app/providers.tsx +42 -0
- package/templates/react-monorepo/files/apps/landing/src/app/router.tsx +21 -0
- package/templates/react-monorepo/files/apps/landing/src/app/store.ts +18 -0
- package/templates/react-monorepo/files/apps/landing/src/features/seo/routes.ts +65 -0
- package/templates/react-monorepo/files/apps/landing/src/lib/env.ts +10 -0
- package/templates/react-monorepo/files/apps/landing/src/main.tsx +14 -0
- package/templates/react-monorepo/files/apps/landing/src/routes/home.tsx +18 -0
- package/templates/react-monorepo/files/apps/landing/src/vite-env.d.ts +15 -0
- package/templates/react-monorepo/files/apps/landing/tsconfig.json +10 -0
- package/templates/react-monorepo/files/apps/landing/vite.config.ts +169 -0
- package/templates/react-monorepo/files/build.sh +61 -0
- package/templates/react-monorepo/files/docker/nginx.conf +136 -0
- package/templates/react-monorepo/files/package.json +37 -0
- package/templates/react-monorepo/files/packages/.gitkeep +0 -0
- package/templates/react-monorepo/files/packages/api/eslint.config.mjs +3 -0
- package/templates/react-monorepo/files/packages/api/package.json +30 -0
- package/templates/react-monorepo/files/packages/api/src/base-api.ts +24 -0
- package/templates/react-monorepo/files/packages/api/src/base-query.ts +29 -0
- package/templates/react-monorepo/files/packages/api/src/config.ts +21 -0
- package/templates/react-monorepo/files/packages/api/src/index.ts +15 -0
- package/templates/react-monorepo/files/packages/api/src/realtime-events.ts +34 -0
- package/templates/react-monorepo/files/packages/api/src/socket.ts +41 -0
- package/templates/react-monorepo/files/packages/api/src/store.ts +39 -0
- package/templates/react-monorepo/files/packages/api/src/upload-query.ts +115 -0
- package/templates/react-monorepo/files/packages/api/tsconfig.json +4 -0
- package/templates/react-monorepo/files/packages/auth/eslint.config.mjs +3 -0
- package/templates/react-monorepo/files/packages/auth/package.json +33 -0
- package/templates/react-monorepo/files/packages/auth/src/client.ts +27 -0
- package/templates/react-monorepo/files/packages/auth/src/config.ts +22 -0
- package/templates/react-monorepo/files/packages/auth/src/guards.tsx +61 -0
- package/templates/react-monorepo/files/packages/auth/src/hooks.ts +13 -0
- package/templates/react-monorepo/files/packages/auth/src/index.ts +20 -0
- package/templates/react-monorepo/files/packages/auth/src/logout.ts +23 -0
- package/templates/react-monorepo/files/packages/auth/src/provider.tsx +52 -0
- package/templates/react-monorepo/files/packages/auth/src/redirect.ts +37 -0
- package/templates/react-monorepo/files/packages/auth/src/slice.ts +54 -0
- package/templates/react-monorepo/files/packages/auth/tsconfig.json +4 -0
- package/templates/react-monorepo/files/packages/config/README.md +47 -0
- package/templates/react-monorepo/files/packages/config/eslint/base.mjs +83 -0
- package/templates/react-monorepo/files/packages/config/package.json +37 -0
- package/templates/react-monorepo/files/packages/config/tailwind/theme.css +48 -0
- package/templates/react-monorepo/files/packages/config/tsconfig/base.json +22 -0
- package/templates/react-monorepo/files/packages/config/tsconfig/node.json +9 -0
- package/templates/react-monorepo/files/packages/config/tsconfig/react.json +9 -0
- package/templates/react-monorepo/files/packages/config/vite/index.d.ts +18 -0
- package/templates/react-monorepo/files/packages/config/vite/index.mjs +129 -0
- package/templates/react-monorepo/files/packages/hooks/eslint.config.mjs +3 -0
- package/templates/react-monorepo/files/packages/hooks/package.json +16 -0
- package/templates/react-monorepo/files/packages/hooks/src/index.ts +3 -0
- package/templates/react-monorepo/files/packages/hooks/tsconfig.json +4 -0
- package/templates/react-monorepo/files/packages/layouts/eslint.config.mjs +3 -0
- package/templates/react-monorepo/files/packages/layouts/package.json +30 -0
- package/templates/react-monorepo/files/packages/layouts/src/app-shell/app-shell.tsx +225 -0
- package/templates/react-monorepo/files/packages/layouts/src/app-shell/user-menu.tsx +74 -0
- package/templates/react-monorepo/files/packages/layouts/src/auth-layout.tsx +137 -0
- package/templates/react-monorepo/files/packages/layouts/src/error-boundary.tsx +38 -0
- package/templates/react-monorepo/files/packages/layouts/src/index.ts +23 -0
- package/templates/react-monorepo/files/packages/layouts/src/marketing/marketing-layout.tsx +29 -0
- package/templates/react-monorepo/files/packages/layouts/src/marketing/section-heading.tsx +38 -0
- package/templates/react-monorepo/files/packages/layouts/src/marketing/section.tsx +30 -0
- package/templates/react-monorepo/files/packages/layouts/src/states/app-shell-skeleton.tsx +47 -0
- package/templates/react-monorepo/files/packages/layouts/src/states/empty.tsx +22 -0
- package/templates/react-monorepo/files/packages/layouts/src/states/forbidden.tsx +14 -0
- package/templates/react-monorepo/files/packages/layouts/src/states/loading.tsx +11 -0
- package/templates/react-monorepo/files/packages/layouts/src/states/not-found.tsx +21 -0
- package/templates/react-monorepo/files/packages/layouts/src/states/page-skeleton.tsx +39 -0
- package/templates/react-monorepo/files/packages/layouts/src/states/route-fallback.tsx +26 -0
- package/templates/react-monorepo/files/packages/layouts/src/states/state-screen.tsx +22 -0
- package/templates/react-monorepo/files/packages/layouts/tsconfig.json +4 -0
- package/templates/react-monorepo/files/packages/types/.bin/openapi.js +32 -0
- package/templates/react-monorepo/files/packages/types/.bin/secrets.js +57 -0
- package/templates/react-monorepo/files/packages/types/README.md +28 -0
- package/templates/react-monorepo/files/packages/types/eslint.config.mjs +3 -0
- package/templates/react-monorepo/files/packages/types/openapi-ts.config.ts +22 -0
- package/templates/react-monorepo/files/packages/types/package.json +29 -0
- package/templates/react-monorepo/files/packages/types/src/index.ts +4 -0
- package/templates/react-monorepo/files/packages/types/src/types/api/index.ts +9 -0
- package/templates/react-monorepo/files/packages/types/src/types/api/zod.gen.ts +5 -0
- package/templates/react-monorepo/files/packages/types/tsconfig.json +7 -0
- package/templates/react-monorepo/files/packages/ui/components.json +21 -0
- package/templates/react-monorepo/files/packages/ui/eslint.config.mjs +13 -0
- package/templates/react-monorepo/files/packages/ui/package.json +44 -0
- package/templates/react-monorepo/files/packages/ui/src/components/brand/logo.tsx +51 -0
- package/templates/react-monorepo/files/packages/ui/src/components/brand/social-icons.tsx +37 -0
- package/templates/react-monorepo/files/packages/ui/src/components/form/form.tsx +120 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/alert.tsx +25 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/button.tsx +43 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/calendar.tsx +78 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/card.tsx +44 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/checkbox.tsx +16 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/date-picker.tsx +76 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/input.tsx +22 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/label.tsx +19 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/modal.tsx +94 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/popover.tsx +31 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/progress.tsx +33 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/search-input.tsx +69 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/select.tsx +80 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/skeleton.tsx +12 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/sonner.tsx +23 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/spinner.tsx +8 -0
- package/templates/react-monorepo/files/packages/ui/src/components/ui/textarea.tsx +22 -0
- package/templates/react-monorepo/files/packages/ui/src/index.ts +45 -0
- package/templates/react-monorepo/files/packages/ui/src/lib/utils.ts +7 -0
- package/templates/react-monorepo/files/packages/ui/src/lib/zod-setup.ts +28 -0
- package/templates/react-monorepo/files/packages/ui/src/meta/brand.ts +18 -0
- package/templates/react-monorepo/files/packages/ui/src/meta/meta-context.ts +30 -0
- package/templates/react-monorepo/files/packages/ui/src/meta/meta-provider.tsx +24 -0
- package/templates/react-monorepo/files/packages/ui/src/meta/page-meta.tsx +69 -0
- package/templates/react-monorepo/files/packages/ui/src/meta/use-meta-config.ts +11 -0
- package/templates/react-monorepo/files/packages/ui/src/styles/globals.css +285 -0
- package/templates/react-monorepo/files/packages/ui/src/theme/init-script.ts +23 -0
- package/templates/react-monorepo/files/packages/ui/src/theme/theme-colors.ts +14 -0
- package/templates/react-monorepo/files/packages/ui/src/theme/theme-context.ts +60 -0
- package/templates/react-monorepo/files/packages/ui/src/theme/theme-provider.tsx +101 -0
- package/templates/react-monorepo/files/packages/ui/src/theme/theme-toggle.tsx +40 -0
- package/templates/react-monorepo/files/packages/ui/src/theme/use-theme.ts +11 -0
- package/templates/react-monorepo/files/packages/ui/tsconfig.json +9 -0
- package/templates/react-monorepo/files/turbo.json +24 -0
- package/templates/react-monorepo/template.json +230 -0
package/cli/stack.mjs
ADDED
|
@@ -0,0 +1,672 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `stack` — scaffold a new project from a house template.
|
|
4
|
+
*
|
|
5
|
+
* Plain Node ESM with zero dependencies and no build step, so it runs the same
|
|
6
|
+
* from the npm package, the Claude Code plugin, or a git checkout.
|
|
7
|
+
*
|
|
8
|
+
* stack list
|
|
9
|
+
* stack info <template>
|
|
10
|
+
* stack new <template> <dir> [--with a,b] [--without c] [--all]
|
|
11
|
+
* stack extract <template> [--source dir] [--overwrite] [--prune]
|
|
12
|
+
* stack doctor [template]
|
|
13
|
+
*/
|
|
14
|
+
import path from 'node:path';
|
|
15
|
+
import fs from 'node:fs';
|
|
16
|
+
import { fileURLToPath } from 'node:url';
|
|
17
|
+
import { parseArgs } from 'node:util';
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
loadManifest,
|
|
21
|
+
listTemplates,
|
|
22
|
+
resolveFeatures,
|
|
23
|
+
featureSummary,
|
|
24
|
+
expandHome,
|
|
25
|
+
sourceConfig
|
|
26
|
+
} from './src/manifest.mjs';
|
|
27
|
+
import { generate } from './src/generate.mjs';
|
|
28
|
+
import { extract } from './src/extract.mjs';
|
|
29
|
+
import { runHooks } from './src/hooks.mjs';
|
|
30
|
+
import {
|
|
31
|
+
collectFeatureNames,
|
|
32
|
+
stripFeatures,
|
|
33
|
+
bracketBalance
|
|
34
|
+
} from './src/strip.mjs';
|
|
35
|
+
import { walk, matcher, isTextFile, readText, DEFAULT_SKIP_DIRS } from './src/fsx.mjs';
|
|
36
|
+
import { kebab, interpolate } from './src/tokens.mjs';
|
|
37
|
+
|
|
38
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
39
|
+
const VERSION = JSON.parse(
|
|
40
|
+
fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8')
|
|
41
|
+
).version;
|
|
42
|
+
|
|
43
|
+
// Colour only when attached to a terminal, so piping the output into a file
|
|
44
|
+
// or another tool yields clean text.
|
|
45
|
+
const COLOR = process.stdout.isTTY && !process.env.NO_COLOR;
|
|
46
|
+
const paint = (code) => (s) => (COLOR ? `\x1b[${code}m${s}\x1b[0m` : String(s));
|
|
47
|
+
const c = {
|
|
48
|
+
bold: paint(1),
|
|
49
|
+
dim: paint(2),
|
|
50
|
+
green: paint(32),
|
|
51
|
+
yellow: paint(33),
|
|
52
|
+
red: paint(31),
|
|
53
|
+
cyan: paint(36)
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const log = (...args) => console.log(...args);
|
|
57
|
+
// Accepts `--with a,b` and repeated `--with a --with b` alike.
|
|
58
|
+
const csv = (v) =>
|
|
59
|
+
[]
|
|
60
|
+
.concat(v ?? [])
|
|
61
|
+
.flatMap((s) => String(s).split(','))
|
|
62
|
+
.map((s) => s.trim())
|
|
63
|
+
.filter(Boolean);
|
|
64
|
+
|
|
65
|
+
const USAGE = `
|
|
66
|
+
${c.bold('stack')} — scaffold a new project from a house template
|
|
67
|
+
|
|
68
|
+
${c.bold('Commands')}
|
|
69
|
+
list List available templates
|
|
70
|
+
info <template> Show a template's features and defaults
|
|
71
|
+
new <template> <dir> [options] Generate a project
|
|
72
|
+
extract <template> [options] Refresh a template from its source repo
|
|
73
|
+
doctor [template] Validate templates against their manifests
|
|
74
|
+
version Print the stack version (also --version)
|
|
75
|
+
|
|
76
|
+
${c.bold('new options')}
|
|
77
|
+
--name <name> Project name ${c.dim('(default: basename of <dir>)')}
|
|
78
|
+
--scope <scope> npm scope, no @ ${c.dim('(default: --name)')}
|
|
79
|
+
--description <s> Package description
|
|
80
|
+
--port <n> Default listen port
|
|
81
|
+
--with a,b Enable optional features (repeatable)
|
|
82
|
+
--without a,b Disable default features (repeatable)
|
|
83
|
+
--all Enable every optional feature
|
|
84
|
+
--no-hooks Skip install / prisma generate / git init
|
|
85
|
+
--force Write into a non-empty directory
|
|
86
|
+
--dry-run Print what would happen, write nothing
|
|
87
|
+
|
|
88
|
+
${c.bold('extract options')}
|
|
89
|
+
--source <dir> Override the source path in stacks.local.json
|
|
90
|
+
--overwrite Replace template files that already differ
|
|
91
|
+
--prune Delete template files the source no longer has
|
|
92
|
+
--dry-run
|
|
93
|
+
|
|
94
|
+
${c.bold('Examples')}
|
|
95
|
+
stack new nest-api ~/Projects/acme/api --with realtime,media
|
|
96
|
+
stack new react-monorepo ~/Projects/acme/web --without landing
|
|
97
|
+
stack extract nest-api --source ~/Projects/acme/web/backend
|
|
98
|
+
`;
|
|
99
|
+
|
|
100
|
+
function cmdList() {
|
|
101
|
+
const names = listTemplates(ROOT);
|
|
102
|
+
if (names.length === 0) {
|
|
103
|
+
log(c.yellow('No templates found in'), path.join(ROOT, 'templates'));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
log('');
|
|
107
|
+
for (const name of names) {
|
|
108
|
+
const m = loadManifest(ROOT, name);
|
|
109
|
+
const hasFiles = fs.existsSync(m.__filesDir);
|
|
110
|
+
const count = Object.keys(m.features).length;
|
|
111
|
+
log(
|
|
112
|
+
` ${c.bold(c.cyan(name.padEnd(18)))} ${m.title || ''}` +
|
|
113
|
+
(hasFiles ? '' : c.yellow(' [not extracted]'))
|
|
114
|
+
);
|
|
115
|
+
if (m.description) log(` ${' '.repeat(18)} ${c.dim(m.description)}`);
|
|
116
|
+
log(` ${' '.repeat(18)} ${c.dim(`${count} features`)}`);
|
|
117
|
+
log('');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function cmdInfo(name) {
|
|
122
|
+
const m = loadManifest(ROOT, name);
|
|
123
|
+
log('');
|
|
124
|
+
log(` ${c.bold(m.title || m.name)} ${c.dim(m.name)}`);
|
|
125
|
+
if (m.description) log(` ${m.description}`);
|
|
126
|
+
log('');
|
|
127
|
+
const core = [];
|
|
128
|
+
const on = [];
|
|
129
|
+
const off = [];
|
|
130
|
+
for (const [fname, def] of Object.entries(m.features)) {
|
|
131
|
+
const row = ` ${fname.padEnd(20)} ${c.dim(def.title || '')}`;
|
|
132
|
+
if (def.core) core.push(row);
|
|
133
|
+
else if (def.default) on.push(row);
|
|
134
|
+
else off.push(row);
|
|
135
|
+
}
|
|
136
|
+
if (core.length) {
|
|
137
|
+
log(c.bold(' Always included'));
|
|
138
|
+
core.forEach((r) => log(r));
|
|
139
|
+
log('');
|
|
140
|
+
}
|
|
141
|
+
if (on.length) {
|
|
142
|
+
log(c.bold(' On by default') + c.dim(' (--without <name> to drop)'));
|
|
143
|
+
on.forEach((r) => log(r));
|
|
144
|
+
log('');
|
|
145
|
+
}
|
|
146
|
+
if (off.length) {
|
|
147
|
+
log(c.bold(' Opt-in') + c.dim(' (--with <name> to add)'));
|
|
148
|
+
off.forEach((r) => log(r));
|
|
149
|
+
log('');
|
|
150
|
+
}
|
|
151
|
+
for (const [fname, def] of Object.entries(m.features)) {
|
|
152
|
+
if (def.requires?.length) {
|
|
153
|
+
log(c.dim(` ${fname} requires ${def.requires.join(', ')}`));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
log('');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function cmdNew(args, values) {
|
|
160
|
+
const [templateName, dirArg] = args;
|
|
161
|
+
if (!templateName || !dirArg) {
|
|
162
|
+
log(c.red('Usage: stack new <template> <dir>'));
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const manifest = loadManifest(ROOT, templateName);
|
|
167
|
+
const target = path.resolve(expandHome(dirArg));
|
|
168
|
+
const name = kebab(values.name || path.basename(target));
|
|
169
|
+
|
|
170
|
+
const options = {
|
|
171
|
+
name,
|
|
172
|
+
toolVersion: VERSION,
|
|
173
|
+
scope: values.scope,
|
|
174
|
+
description: values.description,
|
|
175
|
+
port: values.port ? Number(values.port) : undefined,
|
|
176
|
+
author: values.author,
|
|
177
|
+
with: csv(values.with),
|
|
178
|
+
without: csv(values.without),
|
|
179
|
+
all: Boolean(values.all),
|
|
180
|
+
dryRun: Boolean(values['dry-run']),
|
|
181
|
+
force: Boolean(values.force)
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const { report, ctx, enabled } = generate(manifest, target, options);
|
|
185
|
+
|
|
186
|
+
log('');
|
|
187
|
+
log(` ${c.bold(manifest.title || manifest.name)} → ${c.cyan(target)}`);
|
|
188
|
+
log(` ${c.dim('name')} ${ctx.name}`);
|
|
189
|
+
log(` ${c.dim('scope')} @${ctx.scope}`);
|
|
190
|
+
log(` ${c.dim('features')} ${c.green(report.enabled.join(', ') || '—')}`);
|
|
191
|
+
if (report.disabled.length) {
|
|
192
|
+
log(` ${c.dim('omitted')} ${c.dim(report.disabled.join(', '))}`);
|
|
193
|
+
}
|
|
194
|
+
log(
|
|
195
|
+
` ${c.dim('files')} ${report.written.length} written, ` +
|
|
196
|
+
`${report.dropped.length} dropped, ${report.pruned} package keys pruned`
|
|
197
|
+
);
|
|
198
|
+
log('');
|
|
199
|
+
|
|
200
|
+
if (options.dryRun) {
|
|
201
|
+
log(c.yellow(' dry run — nothing written'));
|
|
202
|
+
log('');
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (manifest.hooks?.length) {
|
|
207
|
+
log(c.bold(' Post-generation'));
|
|
208
|
+
runHooks(manifest, target, enabled, ctx, {
|
|
209
|
+
skip: values['no-hooks'],
|
|
210
|
+
log
|
|
211
|
+
});
|
|
212
|
+
log('');
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
log(c.green(' Done.'));
|
|
216
|
+
if (manifest.nextSteps?.length) {
|
|
217
|
+
log('');
|
|
218
|
+
log(c.bold(' Next'));
|
|
219
|
+
for (const step of manifest.nextSteps) log(` ${interpolate(step, ctx)}`);
|
|
220
|
+
}
|
|
221
|
+
log('');
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function cmdExtract(args, values) {
|
|
225
|
+
const [templateName] = args;
|
|
226
|
+
if (!templateName) {
|
|
227
|
+
log(c.red('Usage: stack extract <template>'));
|
|
228
|
+
process.exit(1);
|
|
229
|
+
}
|
|
230
|
+
// npm and Claude Code install stack as a copy that the next update
|
|
231
|
+
// replaces, so an extract there would write into files that get thrown away.
|
|
232
|
+
if (!fs.existsSync(path.join(ROOT, '.git'))) {
|
|
233
|
+
throw new Error(
|
|
234
|
+
`extract writes into the templates, so it needs a git checkout, not an installed copy (${ROOT}).\n` +
|
|
235
|
+
' git clone https://github.com/aurostack-org/stacks.git && cd stacks && bash install.sh\n' +
|
|
236
|
+
' then run extract from that checkout.'
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
const manifest = loadManifest(ROOT, templateName);
|
|
240
|
+
const config = sourceConfig(ROOT, manifest);
|
|
241
|
+
const report = extract(manifest, {
|
|
242
|
+
source: values.source,
|
|
243
|
+
config,
|
|
244
|
+
overwrite: Boolean(values.overwrite),
|
|
245
|
+
prune: Boolean(values.prune),
|
|
246
|
+
dryRun: Boolean(values['dry-run'])
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
log('');
|
|
250
|
+
log(` ${c.bold(manifest.name)} ← ${c.cyan(expandHome(values.source || config.path))}`);
|
|
251
|
+
log(` ${c.dim('copied')} ${report.copied.length}`);
|
|
252
|
+
log(` ${c.dim('unchanged')} ${report.skipped}`);
|
|
253
|
+
if (report.conflicts.length) {
|
|
254
|
+
log(` ${c.yellow('conflicts')} ${report.conflicts.length} ${c.dim('(differ from source; --overwrite to replace)')}`);
|
|
255
|
+
for (const f of report.conflicts.slice(0, 40)) log(` ${c.yellow(f)}`);
|
|
256
|
+
if (report.conflicts.length > 40) {
|
|
257
|
+
log(c.dim(` … ${report.conflicts.length - 40} more`));
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (report.orphans.length) {
|
|
261
|
+
log(` ${c.dim('template-only')} ${report.orphans.length} ${c.dim('(no source counterpart)')}`);
|
|
262
|
+
for (const f of report.orphans.slice(0, 20)) log(` ${c.dim(f)}`);
|
|
263
|
+
if (report.orphans.length > 20) {
|
|
264
|
+
log(c.dim(` … ${report.orphans.length - 20} more`));
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
log('');
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* tsconfig.json and nest-cli.json are JSONC — comments and trailing commas are
|
|
273
|
+
* legal there and must not be reported as damage.
|
|
274
|
+
*/
|
|
275
|
+
function stripJsonc(text) {
|
|
276
|
+
let out = '';
|
|
277
|
+
let inString = false;
|
|
278
|
+
let inLine = false;
|
|
279
|
+
let inBlock = false;
|
|
280
|
+
for (let i = 0; i < text.length; i++) {
|
|
281
|
+
const ch = text[i];
|
|
282
|
+
const next = text[i + 1];
|
|
283
|
+
if (inLine) {
|
|
284
|
+
if (ch === '\n') {
|
|
285
|
+
inLine = false;
|
|
286
|
+
out += ch;
|
|
287
|
+
}
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
if (inBlock) {
|
|
291
|
+
if (ch === '*' && next === '/') {
|
|
292
|
+
inBlock = false;
|
|
293
|
+
i++;
|
|
294
|
+
}
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
if (inString) {
|
|
298
|
+
out += ch;
|
|
299
|
+
if (ch === '\\') {
|
|
300
|
+
out += next ?? '';
|
|
301
|
+
i++;
|
|
302
|
+
} else if (ch === '"') {
|
|
303
|
+
inString = false;
|
|
304
|
+
}
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
if (ch === '"') {
|
|
308
|
+
inString = true;
|
|
309
|
+
out += ch;
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
if (ch === '/' && next === '/') {
|
|
313
|
+
inLine = true;
|
|
314
|
+
i++;
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
if (ch === '/' && next === '*') {
|
|
318
|
+
inBlock = true;
|
|
319
|
+
i++;
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
out += ch;
|
|
323
|
+
}
|
|
324
|
+
return out.replace(/,(\s*[}\]])/g, '$1');
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Feature selections worth checking. Not the full 2^n power set — the two
|
|
330
|
+
* extremes plus each optional feature flipped on its own from the defaults,
|
|
331
|
+
* which is where a missed annotation actually shows up.
|
|
332
|
+
*/
|
|
333
|
+
function presetsFor(manifest) {
|
|
334
|
+
const optional = Object.entries(manifest.features)
|
|
335
|
+
.filter(([, def]) => !def.core)
|
|
336
|
+
.map(([name]) => name);
|
|
337
|
+
|
|
338
|
+
const presets = [
|
|
339
|
+
{ label: 'all', opts: { with: [], without: [], all: true } },
|
|
340
|
+
{ label: 'defaults', opts: { with: [], without: [] } }
|
|
341
|
+
];
|
|
342
|
+
// Everything that transitively requires `name`, so dropping a dependency also
|
|
343
|
+
// drops its dependents rather than being reported as an impossible selection.
|
|
344
|
+
const closureOf = (name) => {
|
|
345
|
+
const out = new Set([name]);
|
|
346
|
+
let grew = true;
|
|
347
|
+
while (grew) {
|
|
348
|
+
grew = false;
|
|
349
|
+
for (const [other, def] of Object.entries(manifest.features)) {
|
|
350
|
+
if (out.has(other)) continue;
|
|
351
|
+
if ((def.requires || []).some((r) => out.has(r))) {
|
|
352
|
+
out.add(other);
|
|
353
|
+
grew = true;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return [...out];
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
for (const name of optional) {
|
|
361
|
+
const def = manifest.features[name];
|
|
362
|
+
if (def.default) {
|
|
363
|
+
const without = closureOf(name).filter((f) => !manifest.features[f].core);
|
|
364
|
+
const label =
|
|
365
|
+
without.length > 1 ? `without ${name} (+dependents)` : `without ${name}`;
|
|
366
|
+
presets.push({ label, opts: { with: [], without } });
|
|
367
|
+
} else {
|
|
368
|
+
presets.push({ label: `with ${name}`, opts: { with: [name], without: [] } });
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return presets;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const IMPORT_RE = /(?:from|import)\s+['"]([^'"]+)['"]/g;
|
|
375
|
+
const RESOLVE_EXT = ['', '.ts', '.tsx', '.js', '.mjs', '.json', '/index.ts', '/index.tsx'];
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Candidate on-disk paths for one specifier.
|
|
379
|
+
*
|
|
380
|
+
* ESM TypeScript (`moduleResolution: nodenext`) writes `./foo.js` for a file
|
|
381
|
+
* that is `./foo.ts` on disk — the extension names the *output*. Resolving the
|
|
382
|
+
* literal string finds nothing, so rewrite that form as well.
|
|
383
|
+
*/
|
|
384
|
+
function resolutionCandidates(target) {
|
|
385
|
+
const bases = [target];
|
|
386
|
+
const jsLike = target.match(/^(.*)\.(js|mjs|cjs)$/);
|
|
387
|
+
if (jsLike) bases.push(jsLike[1]);
|
|
388
|
+
return bases.flatMap((base) => RESOLVE_EXT.map((ext) => base + ext));
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Resolve intra-project imports against the files a selection actually keeps.
|
|
393
|
+
*
|
|
394
|
+
* This is the check that catches a barrel re-exporting a module the selection
|
|
395
|
+
* deleted — `export * from './queue.module'` in a build with no queue. Nothing
|
|
396
|
+
* else notices until the generated project fails to compile.
|
|
397
|
+
*/
|
|
398
|
+
function danglingImports(manifest, enabled, files, aliasRoots) {
|
|
399
|
+
// Paths produced by a build step (the Prisma client, say) do not exist in the
|
|
400
|
+
// template and must not be reported as missing.
|
|
401
|
+
const isGenerated = matcher(manifest.generatedPaths || []);
|
|
402
|
+
const dropped = [];
|
|
403
|
+
for (const [fname, def] of Object.entries(manifest.features)) {
|
|
404
|
+
if (enabled.has(fname) || !def.files?.length) continue;
|
|
405
|
+
dropped.push(matcher(def.files));
|
|
406
|
+
}
|
|
407
|
+
const kept = files.filter((rel) => !dropped.some((m) => m(rel)));
|
|
408
|
+
const keptSet = new Set(kept);
|
|
409
|
+
const resolves = (target) =>
|
|
410
|
+
resolutionCandidates(target).some((candidate) => keptSet.has(candidate));
|
|
411
|
+
|
|
412
|
+
const problems = [];
|
|
413
|
+
for (const rel of kept) {
|
|
414
|
+
if (!/\.tsx?$/.test(rel)) continue;
|
|
415
|
+
const { content } = stripFeatures(
|
|
416
|
+
readText(path.join(manifest.__filesDir, rel)),
|
|
417
|
+
enabled
|
|
418
|
+
);
|
|
419
|
+
const dir = path.posix.dirname(rel);
|
|
420
|
+
for (const m of content.matchAll(IMPORT_RE)) {
|
|
421
|
+
const spec = m[1];
|
|
422
|
+
let target = null;
|
|
423
|
+
|
|
424
|
+
if (spec.startsWith('.')) {
|
|
425
|
+
target = path.posix.normalize(path.posix.join(dir, spec));
|
|
426
|
+
} else {
|
|
427
|
+
const alias = Object.keys(aliasRoots).find((a) => spec.startsWith(a));
|
|
428
|
+
if (alias) {
|
|
429
|
+
// Skip aliases pointing at build output (e.g. the Prisma client),
|
|
430
|
+
// which only exists after a generate step.
|
|
431
|
+
if (aliasRoots[alias] === null) continue;
|
|
432
|
+
target = path.posix.join(aliasRoots[alias], spec.slice(alias.length));
|
|
433
|
+
} else {
|
|
434
|
+
// A bare specifier is only ours if its first segment is a real
|
|
435
|
+
// top-level source directory (tsconfig baseUrl: ./src).
|
|
436
|
+
const head = spec.split('/')[0];
|
|
437
|
+
if (!kept.some((f) => f.startsWith(`src/${head}/`) || f === `src/${head}.ts`)) {
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
target = path.posix.join('src', spec);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
if (target && !isGenerated(target) && !resolves(target)) {
|
|
444
|
+
problems.push(`${rel} imports "${spec}", which this selection does not include`);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
return problems;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function doctorOne(name) {
|
|
452
|
+
const m = loadManifest(ROOT, name);
|
|
453
|
+
const problems = [];
|
|
454
|
+
|
|
455
|
+
if (!fs.existsSync(m.__filesDir)) {
|
|
456
|
+
return [`${name}: no files/ directory — run \`stack extract ${name}\``];
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
const files = walk(m.__filesDir, { skipDirs: DEFAULT_SKIP_DIRS });
|
|
460
|
+
const declared = new Set(Object.keys(m.features));
|
|
461
|
+
const referenced = new Set();
|
|
462
|
+
|
|
463
|
+
for (const rel of files) {
|
|
464
|
+
if (!isTextFile(rel)) continue;
|
|
465
|
+
for (const fname of collectFeatureNames(readText(path.join(m.__filesDir, rel)))) {
|
|
466
|
+
referenced.add(fname);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
for (const fname of referenced) {
|
|
471
|
+
if (!declared.has(fname)) {
|
|
472
|
+
problems.push(
|
|
473
|
+
`${name}: files reference feature "${fname}", which template.json does not declare ` +
|
|
474
|
+
`(a typo here silently deletes code)`
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// A feature whose file globs match nothing is almost always a stale path.
|
|
480
|
+
for (const [fname, def] of Object.entries(m.features)) {
|
|
481
|
+
if (!def.files?.length) continue;
|
|
482
|
+
const match = matcher(def.files);
|
|
483
|
+
if (!files.some(match)) {
|
|
484
|
+
problems.push(`${name}: feature "${fname}" has files globs that match nothing`);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// Requirements must resolve.
|
|
489
|
+
for (const [fname, def] of Object.entries(m.features)) {
|
|
490
|
+
for (const dep of def.requires || []) {
|
|
491
|
+
if (!declared.has(dep)) {
|
|
492
|
+
problems.push(`${name}: feature "${fname}" requires undeclared "${dep}"`);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// TypeScript must survive stripping with its brackets still balanced. This is
|
|
498
|
+
// what catches an inline marker parked on the closing line of a multi-line
|
|
499
|
+
// import or object literal — the template itself compiles, so only a
|
|
500
|
+
// generated project would ever reveal it.
|
|
501
|
+
// .tsx is excluded: JSX prose ("you're") defeats a naive string tokenizer,
|
|
502
|
+
// and the email templates it covers carry no markers anyway.
|
|
503
|
+
const presets = presetsFor(m);
|
|
504
|
+
const seenImportProblems = new Set();
|
|
505
|
+
|
|
506
|
+
for (const { label, opts } of presets) {
|
|
507
|
+
let enabled;
|
|
508
|
+
try {
|
|
509
|
+
enabled = resolveFeatures(m, opts);
|
|
510
|
+
} catch {
|
|
511
|
+
continue; // an impossible selection is not a template defect
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// TypeScript must survive stripping with its brackets still balanced —
|
|
515
|
+
// this is what catches an inline marker parked on the closing line of a
|
|
516
|
+
// multi-line import or object literal.
|
|
517
|
+
for (const rel of files) {
|
|
518
|
+
if (!rel.endsWith('.ts')) continue;
|
|
519
|
+
const raw = readText(path.join(m.__filesDir, rel));
|
|
520
|
+
if (!raw.includes('@feature')) continue;
|
|
521
|
+
if (bracketBalance(raw) !== 0) {
|
|
522
|
+
if (label === 'all') {
|
|
523
|
+
problems.push(
|
|
524
|
+
`${name}: ${rel} does not have balanced brackets in the template itself`
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
const balance = bracketBalance(stripFeatures(raw, enabled).content);
|
|
530
|
+
if (balance !== 0) {
|
|
531
|
+
problems.push(
|
|
532
|
+
`${name}: ${rel} is left unbalanced (${balance > 0 ? '+' : ''}${balance}) ` +
|
|
533
|
+
`with [${label}] — a marker is probably on the closing line of a ` +
|
|
534
|
+
`multi-line construct; wrap the whole thing in @feature:start/@feature:end`
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// JSON must still parse — stripping must never leave half an object.
|
|
540
|
+
for (const rel of files) {
|
|
541
|
+
if (path.extname(rel) !== '.json') continue;
|
|
542
|
+
const { content } = stripFeatures(readText(path.join(m.__filesDir, rel)), enabled);
|
|
543
|
+
try {
|
|
544
|
+
JSON.parse(stripJsonc(content));
|
|
545
|
+
} catch (err) {
|
|
546
|
+
problems.push(`${name}: ${rel} is not valid JSON with [${label}] — ${err.message}`);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// And nothing may import a file this selection deleted. Report each
|
|
551
|
+
// distinct problem once, tagged with the first selection that hit it —
|
|
552
|
+
// the same missing annotation otherwise repeats for every preset.
|
|
553
|
+
for (const problem of danglingImports(m, enabled, files, m.aliasRoots || {})) {
|
|
554
|
+
if (seenImportProblems.has(problem)) continue;
|
|
555
|
+
seenImportProblems.add(problem);
|
|
556
|
+
problems.push(`${name}: [${label}] ${problem}`);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
return [...new Set(problems)];
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* The plugin manifests repeat package.json's version; a release that bumps one
|
|
565
|
+
* and not the others ships an npm package and a plugin that disagree. Only
|
|
566
|
+
* checked where the manifests exist (a checkout or the plugin, not npm).
|
|
567
|
+
*/
|
|
568
|
+
function versionProblems() {
|
|
569
|
+
const problems = [];
|
|
570
|
+
for (const rel of ['.claude-plugin/plugin.json', '.claude-plugin/marketplace.json']) {
|
|
571
|
+
const file = path.join(ROOT, rel);
|
|
572
|
+
if (!fs.existsSync(file)) continue;
|
|
573
|
+
const json = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
574
|
+
const versions = rel.endsWith('marketplace.json')
|
|
575
|
+
? (json.plugins || []).map((p) => p.version)
|
|
576
|
+
: [json.version];
|
|
577
|
+
for (const v of versions) {
|
|
578
|
+
if (v !== VERSION) problems.push(`${rel} says ${v}, package.json says ${VERSION}`);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
return problems;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
function cmdDoctor(args) {
|
|
585
|
+
const names = args[0] ? [args[0]] : listTemplates(ROOT);
|
|
586
|
+
let total = 0;
|
|
587
|
+
log('');
|
|
588
|
+
if (!args[0]) {
|
|
589
|
+
const problems = versionProblems();
|
|
590
|
+
total += problems.length;
|
|
591
|
+
if (problems.length === 0) log(` ${c.green('ok')} version ${VERSION}`);
|
|
592
|
+
else {
|
|
593
|
+
log(` ${c.red('!!')} version`);
|
|
594
|
+
for (const p of problems) log(` ${c.yellow(p)}`);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
for (const name of names) {
|
|
598
|
+
const problems = doctorOne(name);
|
|
599
|
+
total += problems.length;
|
|
600
|
+
if (problems.length === 0) {
|
|
601
|
+
log(` ${c.green('ok')} ${name}`);
|
|
602
|
+
} else {
|
|
603
|
+
log(` ${c.red('!!')} ${name}`);
|
|
604
|
+
for (const p of problems) log(` ${c.yellow(p)}`);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
log('');
|
|
608
|
+
if (total > 0) process.exit(1);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
function main() {
|
|
612
|
+
const { values, positionals } = parseArgs({
|
|
613
|
+
allowPositionals: true,
|
|
614
|
+
strict: false,
|
|
615
|
+
options: {
|
|
616
|
+
name: { type: 'string' },
|
|
617
|
+
scope: { type: 'string' },
|
|
618
|
+
description: { type: 'string' },
|
|
619
|
+
author: { type: 'string' },
|
|
620
|
+
port: { type: 'string' },
|
|
621
|
+
with: { type: 'string', multiple: true },
|
|
622
|
+
without: { type: 'string', multiple: true },
|
|
623
|
+
source: { type: 'string' },
|
|
624
|
+
all: { type: 'boolean' },
|
|
625
|
+
force: { type: 'boolean' },
|
|
626
|
+
overwrite: { type: 'boolean' },
|
|
627
|
+
prune: { type: 'boolean' },
|
|
628
|
+
'dry-run': { type: 'boolean' },
|
|
629
|
+
'no-hooks': { type: 'boolean' },
|
|
630
|
+
help: { type: 'boolean', short: 'h' },
|
|
631
|
+
version: { type: 'boolean', short: 'v' }
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
|
|
635
|
+
const [command, ...rest] = positionals;
|
|
636
|
+
|
|
637
|
+
if (values.version || command === 'version') {
|
|
638
|
+
log(VERSION);
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
if (!command || values.help || command === 'help') {
|
|
643
|
+
log(USAGE);
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
switch (command) {
|
|
648
|
+
case 'list':
|
|
649
|
+
return cmdList();
|
|
650
|
+
case 'info':
|
|
651
|
+
return cmdInfo(rest[0]);
|
|
652
|
+
case 'new':
|
|
653
|
+
return cmdNew(rest, values);
|
|
654
|
+
case 'extract':
|
|
655
|
+
return cmdExtract(rest, values);
|
|
656
|
+
case 'doctor':
|
|
657
|
+
return cmdDoctor(rest);
|
|
658
|
+
default:
|
|
659
|
+
log(c.red(`Unknown command "${command}"`));
|
|
660
|
+
log(USAGE);
|
|
661
|
+
process.exit(1);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
try {
|
|
666
|
+
main();
|
|
667
|
+
} catch (err) {
|
|
668
|
+
console.error('');
|
|
669
|
+
console.error(c.red(` ${err.message}`));
|
|
670
|
+
console.error('');
|
|
671
|
+
process.exit(1);
|
|
672
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aurostack/stacks",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Scaffold new projects from house templates: a NestJS API, React app or Turborepo monorepo, and Node or Python workers. Subtractive templates plus a zero-dependency generator.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Aurostack (https://github.com/aurostack-org)",
|
|
7
|
+
"homepage": "https://github.com/aurostack-org/stacks#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/aurostack-org/stacks.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": "https://github.com/aurostack-org/stacks/issues",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"scaffold",
|
|
15
|
+
"generator",
|
|
16
|
+
"template",
|
|
17
|
+
"boilerplate",
|
|
18
|
+
"nestjs",
|
|
19
|
+
"react",
|
|
20
|
+
"turborepo",
|
|
21
|
+
"cli"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"bin": {
|
|
25
|
+
"stack": "cli/stack.mjs"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"cli/",
|
|
29
|
+
"templates/"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=20.19"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
}
|
|
37
|
+
}
|