spine-framework 0.3.0 → 0.3.2

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.
@@ -18,7 +18,7 @@
18
18
  */
19
19
 
20
20
  import type { Command } from 'commander'
21
- import { existsSync, mkdirSync, writeFileSync, cpSync } from 'fs'
21
+ import { existsSync, mkdirSync, writeFileSync, cpSync, readFileSync } from 'fs'
22
22
  import { resolve, dirname } from 'path'
23
23
  import { fileURLToPath } from 'url'
24
24
  import { execSync } from 'child_process'
@@ -106,11 +106,18 @@ function copyFrameworkFiles(dryRun: boolean): void {
106
106
  { src: 'netlify.toml', dest: 'netlify.toml' },
107
107
  { src: 'vitest.config.ts', dest: 'vitest.config.ts' },
108
108
  { src: 'index.html', dest: 'index.html' },
109
- { src: 'package-project.json', dest: 'package.json' },
109
+ { src: 'package-project.json', dest: 'package.json', template: true },
110
110
  { src: 'STRUCTURE.md', dest: 'STRUCTURE.md' },
111
111
  ]
112
112
 
113
- for (const item of items) {
113
+ // Resolve current framework version from the installed package
114
+ let frameworkVersion = '0.1.0'
115
+ try {
116
+ const fwPkg = JSON.parse(readFileSync(resolve(PACKAGE_ROOT, 'package.json'), 'utf8'))
117
+ frameworkVersion = fwPkg.version || frameworkVersion
118
+ } catch { /* fall through */ }
119
+
120
+ for (const item of items as Array<{ src: string; dest: string; template?: boolean }>) {
114
121
  const src = resolve(PACKAGE_ROOT, item.src)
115
122
  const dest = resolve(PROJECT_ROOT, item.dest)
116
123
 
@@ -119,8 +126,7 @@ function copyFrameworkFiles(dryRun: boolean): void {
119
126
  continue
120
127
  }
121
128
 
122
- // Always overwrite package.json (npm creates a minimal one during install)
123
- if (existsSync(dest) && item.dest !== 'package.json') {
129
+ if (existsSync(dest)) {
124
130
  console.log(` ⏭️ ${item.dest} already exists, skipping`)
125
131
  continue
126
132
  }
@@ -130,7 +136,16 @@ function copyFrameworkFiles(dryRun: boolean): void {
130
136
  continue
131
137
  }
132
138
 
133
- cpSync(src, dest, { recursive: true })
139
+ if (item.template) {
140
+ // Stamp the current framework version into the project package.json
141
+ const templateContent = JSON.parse(readFileSync(src, 'utf8'))
142
+ if (templateContent.dependencies?.['spine-framework']) {
143
+ templateContent.dependencies['spine-framework'] = `^${frameworkVersion}`
144
+ }
145
+ writeFileSync(dest, JSON.stringify(templateContent, null, 2) + '\n', 'utf8')
146
+ } else {
147
+ cpSync(src, dest, { recursive: true })
148
+ }
134
149
  console.log(` ✓ Copied ${item.dest}`)
135
150
  }
136
151
  }
@@ -862,6 +862,15 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_roles_slug_no_app
862
862
  CREATE UNIQUE INDEX IF NOT EXISTS idx_roles_slug_with_app
863
863
  ON public.roles (app_id, slug)
864
864
  WHERE app_id IS NOT NULL;
865
+ -- Non-partial unique constraint required for PostgREST ON CONFLICT upsert on (app_id, slug)
866
+ DO $$ BEGIN
867
+ IF NOT EXISTS (
868
+ SELECT 1 FROM pg_constraint
869
+ WHERE conname = 'roles_app_id_slug_key' AND conrelid = 'public.roles'::regclass
870
+ ) THEN
871
+ ALTER TABLE public.roles ADD CONSTRAINT roles_app_id_slug_key UNIQUE (app_id, slug);
872
+ END IF;
873
+ END $$;
865
874
 
866
875
  CREATE INDEX IF NOT EXISTS idx_se_account ON public.schedule_executions (account_id);
867
876
  CREATE INDEX IF NOT EXISTS idx_se_schedule ON public.schedule_executions (schedule_id);
@@ -1279,6 +1288,22 @@ BEGIN
1279
1288
  END;
1280
1289
  $$;
1281
1290
 
1291
+ -- ---------------------------------------------------------------------------
1292
+ -- App Installations
1293
+ -- Tracks which apps have been installed via `spine-framework install-app`
1294
+ -- ---------------------------------------------------------------------------
1295
+ CREATE TABLE IF NOT EXISTS public.app_installations (
1296
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
1297
+ app_slug text NOT NULL,
1298
+ account_id uuid,
1299
+ is_enabled boolean DEFAULT true,
1300
+ installed_version text,
1301
+ package_name text,
1302
+ created_at timestamptz DEFAULT now(),
1303
+ updated_at timestamptz DEFAULT now(),
1304
+ UNIQUE (app_slug, account_id)
1305
+ );
1306
+
1282
1307
  -- ---------------------------------------------------------------------------
1283
1308
  -- Role Grants
1284
1309
  -- Raw SQL migrations bypass Supabase's automatic grant setup. These grants
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../.framework/cli/commands/init.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAwJxC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,QAcpD"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../.framework/cli/commands/init.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAuKxC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,QAcpD"}
@@ -9,7 +9,7 @@
9
9
  "preview": "netlify dev"
10
10
  },
11
11
  "dependencies": {
12
- "spine-framework": "^0.2.0",
12
+ "spine-framework": "^0.3.1",
13
13
  "@tanstack/react-query": "^5.0.0",
14
14
  "react": "^18.3.0",
15
15
  "react-dom": "^18.3.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spine-framework",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "private": false,
5
5
  "description": "Spine — enterprise application framework built on Supabase + Netlify + React",
6
6
  "type": "module",