@weave-apps/sdk 0.1.3 → 0.1.5

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/bin/compile.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  /**
4
4
  * Weave App Compiler
5
- *
5
+ *
6
6
  * Compiles TypeScript and transpiles to Weave-ready JavaScript
7
7
  */
8
8
 
@@ -34,7 +34,35 @@ if (!fs.existsSync(path.join(appDir, 'src'))) {
34
34
 
35
35
  // Get SDK directory (where this script is located)
36
36
  const sdkDir = path.join(__dirname, '..');
37
- const tscPath = path.join(sdkDir, 'node_modules', '.bin', 'tsc');
37
+
38
+ // Look for TypeScript in multiple locations (app's node_modules first, then SDK's)
39
+ let tscPath = null;
40
+ const possibleTscPaths = [
41
+ // 1. App's node_modules (most common in modern npm)
42
+ path.join(appDir, 'node_modules', '.bin', 'tsc'),
43
+ // 2. SDK's node_modules (if SDK was installed with dependencies)
44
+ path.join(sdkDir, 'node_modules', '.bin', 'tsc'),
45
+ // 3. Global fallback - try npx
46
+ 'npx tsc'
47
+ ];
48
+
49
+ for (const tscCandidate of possibleTscPaths) {
50
+ if (tscCandidate === 'npx tsc') {
51
+ // Special case for npx
52
+ tscPath = tscCandidate;
53
+ break;
54
+ } else if (fs.existsSync(tscCandidate)) {
55
+ tscPath = tscCandidate;
56
+ break;
57
+ }
58
+ }
59
+
60
+ if (!tscPath) {
61
+ console.error('❌ Error: TypeScript not found');
62
+ console.error('Please install TypeScript in your project:');
63
+ console.error(' npm install --save-dev typescript');
64
+ process.exit(1);
65
+ }
38
66
 
39
67
  // Use app's tsconfig.json (which extends SDK's config)
40
68
  const tsconfigPath = path.join(appDir, 'tsconfig.json');
@@ -46,13 +74,6 @@ if (!fs.existsSync(tsconfigPath)) {
46
74
  process.exit(1);
47
75
  }
48
76
 
49
- // Check if TypeScript exists in SDK
50
- if (!fs.existsSync(tscPath)) {
51
- console.error('❌ Error: TypeScript not found in SDK');
52
- console.error('Run: cd SDK && npm install');
53
- process.exit(1);
54
- }
55
-
56
77
  try {
57
78
  // Create dist directory if it doesn't exist
58
79
  const distDir = path.join(appDir, 'dist');
@@ -62,29 +83,33 @@ try {
62
83
 
63
84
  // Step 1: Compile TypeScript using SDK's tsconfig and TypeScript
64
85
  console.log('📦 Compiling TypeScript...');
65
- execSync(`${tscPath} --project ${tsconfigPath} --outDir ${distDir} --rootDir ${appDir}/src`, {
86
+ const tscCommand = tscPath === 'npx tsc'
87
+ ? `npx tsc --project ${tsconfigPath} --outDir ${distDir} --rootDir ${appDir}/src`
88
+ : `"${tscPath}" --project ${tsconfigPath} --outDir ${distDir} --rootDir ${appDir}/src`;
89
+
90
+ execSync(tscCommand, {
66
91
  stdio: 'inherit',
67
92
  cwd: appDir
68
93
  });
69
-
94
+
70
95
  // Rename app.js to {appName}.js
71
96
  const compiledFile = path.join(distDir, 'app.js');
72
97
  const targetFile = path.join(distDir, `${appName}.js`);
73
-
98
+
74
99
  if (fs.existsSync(compiledFile)) {
75
100
  fs.renameSync(compiledFile, targetFile);
76
101
  }
77
-
102
+
78
103
  console.log('✅ TypeScript compiled\n');
79
104
 
80
105
  // Step 2: Extract settings schema and inject into compiled JS
81
106
  console.log('📋 Extracting settings schema...');
82
107
  const extractSchemaScript = path.join(sdkDir, 'scripts', 'extract-settings-schema.js');
83
108
  const sourceFile = path.join(appDir, 'src', 'app.ts');
84
-
109
+
85
110
  if (fs.existsSync(extractSchemaScript) && fs.existsSync(sourceFile)) {
86
111
  try {
87
- execSync(`node ${extractSchemaScript} ${sourceFile} ${targetFile}`, {
112
+ execSync(`node "${extractSchemaScript}" "${sourceFile}" "${targetFile}"`, {
88
113
  stdio: 'inherit',
89
114
  cwd: appDir
90
115
  });
@@ -92,13 +117,13 @@ try {
92
117
  console.warn('⚠️ Schema extraction failed (non-fatal)');
93
118
  }
94
119
  }
95
-
120
+
96
121
  console.log('');
97
122
 
98
123
  // Step 3: Run weave-build to transpile
99
124
  console.log('🔧 Transpiling to Weave format...');
100
125
  const buildScript = path.join(__dirname, 'build.js');
101
- execSync(`node ${buildScript}`, {
126
+ execSync(`node "${buildScript}"`, {
102
127
  stdio: 'inherit',
103
128
  cwd: appDir
104
129
  });
package/bin/init.js CHANGED
@@ -131,7 +131,7 @@ fs.writeFileSync(
131
131
 
132
132
  // Copy app template from SDK
133
133
  const templateDir = path.join(__dirname, '..', 'templates');
134
- const appTemplate = `import { WeaveBaseApp, WeaveAppInfo } from '@weave/app-sdk';
134
+ const appTemplate = `import { WeaveBaseApp, WeaveAppInfo } from '@weave-apps/sdk';
135
135
 
136
136
  // Define settings type for this app, this is a way of injecting settings into the app from the Enterprise Console
137
137
  // These will be auto-extracted and displayed in the Enterprise Console
@@ -254,13 +254,13 @@ if (fs.existsSync(readmePath)) {
254
254
  console.warn('⚠️ Warning: README.md template not found in SDK templates');
255
255
  }
256
256
 
257
- // Copy SIDEKICK_SPEC.md from SDK templates
258
- const specPath = path.join(__dirname, '..', 'templates', 'SIDEKICK_SPEC.md');
257
+ // Copy WEAVE_SPEC.md from SDK templates
258
+ const specPath = path.join(__dirname, '..', 'templates', 'WEAVE_SPEC.md');
259
259
  if (fs.existsSync(specPath)) {
260
260
  const specContent = fs.readFileSync(specPath, 'utf8');
261
- fs.writeFileSync(path.join(projectDir, 'SIDEKICK_SPEC.md'), specContent);
261
+ fs.writeFileSync(path.join(projectDir, 'WEAVE_SPEC.md'), specContent);
262
262
  } else {
263
- console.warn('⚠️ Warning: SIDEKICK_SPEC.md not found in SDK templates');
263
+ console.warn('⚠️ Warning: WEAVE_SPEC.md not found in SDK templates');
264
264
  }
265
265
 
266
266
  // Create .gitignore
@@ -279,7 +279,7 @@ console.log(' ├── src/');
279
279
  console.log(' │ └── app.ts');
280
280
  console.log(' ├── package.json');
281
281
  console.log(' ├── tsconfig.json (extends SDK config)');
282
- console.log(' ├── SIDEKICK_SPEC.md (AI assistant guide)');
282
+ console.log(' ├── WEAVE_SPEC.md (AI assistant guide)');
283
283
  console.log(' └── README.md\n');
284
284
  console.log('🚀 Next steps:');
285
285
  console.log(` cd ${appName}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weave-apps/sdk",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "SDK for building Weave Micro Apps",
5
5
  "publishConfig": {
6
6
  "access": "public"