@cognite/dune 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.
Files changed (46) hide show
  1. package/_templates/app/new/config/eslint.config.mjs.ejs.t +96 -0
  2. package/_templates/app/new/config/tailwind.config.js.ejs.t +1 -5
  3. package/_templates/app/new/config/vite.config.ts.ejs.t +9 -10
  4. package/_templates/app/new/config/vitest.config.ts.ejs.t +4 -5
  5. package/_templates/app/new/config/vitest.setup.ts.ejs.t +1 -2
  6. package/_templates/app/new/cursor/mcp.json.ejs.t +0 -5
  7. package/_templates/app/new/cursor/rules.mdc.ejs.t +1 -2
  8. package/_templates/app/new/prompt.js +29 -29
  9. package/_templates/app/new/root/index.html.ejs.t +3 -3
  10. package/_templates/app/new/root/package.json.ejs.t +11 -5
  11. package/_templates/app/new/src/App.test.tsx.ejs.t +32 -20
  12. package/_templates/app/new/src/App.tsx.ejs.t +118 -7
  13. package/_templates/app/new/src/lib/utils.ts.ejs.t +2 -3
  14. package/_templates/app/new/src/main.tsx.ejs.t +8 -8
  15. package/_templates/app/new/src/styles.css.ejs.t +5 -19
  16. package/bin/auth/authentication-flow.js +16 -14
  17. package/bin/auth/callback-server.js +23 -23
  18. package/bin/auth/certificate-manager.js +13 -13
  19. package/bin/auth/client-credentials.js +31 -32
  20. package/bin/auth/oauth-client.js +7 -7
  21. package/bin/cli.js +31 -30
  22. package/bin/deploy-command.js +32 -32
  23. package/bin/deploy-interactive-command.js +73 -73
  24. package/bin/skills-command.js +43 -26
  25. package/bin/utils/crypto.js +7 -8
  26. package/dist/auth/index.d.ts +10 -13
  27. package/dist/auth/index.js +1 -1
  28. package/dist/{chunk-VIBN7U5H.js → chunk-53VTKDSC.js} +1 -2
  29. package/dist/index.d.ts +2 -2
  30. package/dist/index.js +1 -1
  31. package/package.json +1 -1
  32. package/src/auth/dune-auth-provider.tsx +17 -16
  33. package/src/auth/index.ts +5 -5
  34. package/src/auth/use-dune.ts +5 -4
  35. package/src/auth/utils.ts +18 -18
  36. package/src/deploy/application-deployer.ts +12 -11
  37. package/src/deploy/application-packager.ts +11 -10
  38. package/src/deploy/deploy.ts +7 -6
  39. package/src/deploy/get-sdk.ts +4 -3
  40. package/src/deploy/index.ts +6 -6
  41. package/src/deploy/login.ts +7 -7
  42. package/src/index.ts +1 -1
  43. package/src/vite/fusion-open-plugin.ts +12 -12
  44. package/src/vite/index.ts +1 -1
  45. package/_templates/app/new/config/biome.json.ejs.t +0 -54
  46. package/_templates/app/new/config/components.json.ejs.t +0 -28
@@ -2,15 +2,15 @@
2
2
  * Skills Command
3
3
  *
4
4
  * Manages AI agent skills for Dune apps. Uses the `skills` package (bundled
5
- * dependency) for pull operations.
5
+ * dependency) for pull/list operations.
6
6
  */
7
7
 
8
- import { execFileSync } from "node:child_process";
9
- import { createRequire } from "node:module";
8
+ import { execFileSync } from 'node:child_process';
9
+ import { createRequire } from 'node:module';
10
10
 
11
- const SKILL_SOURCE = "cognitedata/dune-skills";
12
- const SUPPORTED_AGENTS = ["claude-code", "cursor"];
13
- const AGENT_FLAGS = SUPPORTED_AGENTS.flatMap((a) => ["-a", a]);
11
+ const SKILL_SOURCE = 'cognitedata/dune-skills';
12
+ const SUPPORTED_AGENTS = ['claude-code', 'cursor'];
13
+ const AGENT_FLAGS = SUPPORTED_AGENTS.flatMap((a) => ['-a', a]);
14
14
 
15
15
  const require = createRequire(import.meta.url);
16
16
 
@@ -20,9 +20,9 @@ const require = createRequire(import.meta.url);
20
20
  * @param {import('child_process').ExecFileSyncOptions} [options]
21
21
  */
22
22
  export function runSkillsCli(args, options = {}) {
23
- const bin = require.resolve("skills/bin/cli.mjs");
23
+ const bin = require.resolve('skills/bin/cli.mjs');
24
24
  execFileSync(process.execPath, [bin, ...args], {
25
- stdio: "inherit",
25
+ stdio: 'inherit',
26
26
  cwd: process.cwd(),
27
27
  ...options,
28
28
  });
@@ -35,13 +35,14 @@ function printHelp() {
35
35
  console.log(`
36
36
  🧠 Dune Skills — Manage AI agent skills for your Dune app
37
37
 
38
- Installs skills for: ${SUPPORTED_AGENTS.join(", ")}
38
+ Installs skills for: ${SUPPORTED_AGENTS.join(', ')}
39
39
 
40
40
  Usage:
41
41
  npx @cognite/dune skills <command> [options]
42
42
 
43
43
  Commands:
44
44
  pull Pull all skills into your project
45
+ list List installed skills
45
46
  help Show this help message
46
47
 
47
48
  Options for pull:
@@ -53,6 +54,7 @@ Options for pull:
53
54
  Examples:
54
55
  npx @cognite/dune skills pull # Pull all skills
55
56
  npx @cognite/dune skills pull --skill create-client-tool
57
+ npx @cognite/dune skills list # List installed skills
56
58
  `);
57
59
  }
58
60
 
@@ -70,7 +72,7 @@ Examples:
70
72
  * @returns {string[]}
71
73
  */
72
74
  export function defaultPullArgs() {
73
- return ["add", SKILL_SOURCE, ...AGENT_FLAGS, "--skill", "*", "-y"];
75
+ return ['add', SKILL_SOURCE, ...AGENT_FLAGS, '--skill', '*', '-y'];
74
76
  }
75
77
 
76
78
  /**
@@ -80,7 +82,7 @@ export function defaultPullArgs() {
80
82
  function validateSource(source) {
81
83
  if (!/^[\w.-]+\/[\w.-]+$/.test(source)) {
82
84
  console.error(`āŒ Invalid source format: ${source}`);
83
- console.error("Expected: owner/repo (e.g., cognitedata/dune-skills)");
85
+ console.error('Expected: owner/repo (e.g., cognitedata/dune-skills)');
84
86
  process.exit(1);
85
87
  }
86
88
  }
@@ -99,22 +101,22 @@ function handlePull(args) {
99
101
 
100
102
  for (let i = 0; i < args.length; i++) {
101
103
  const arg = args[i];
102
- if (arg === "--source") {
104
+ if (arg === '--source') {
103
105
  source = args[++i];
104
106
  if (!source) {
105
- console.error("āŒ --source requires a value (e.g., cognitedata/dune-skills)");
107
+ console.error('āŒ --source requires a value (e.g., cognitedata/dune-skills)');
106
108
  process.exit(1);
107
109
  }
108
110
  validateSource(source);
109
- } else if (arg === "--skill") {
111
+ } else if (arg === '--skill') {
110
112
  skill_name = args[++i];
111
113
  if (!skill_name) {
112
- console.error("āŒ --skill requires a name");
114
+ console.error('āŒ --skill requires a name');
113
115
  process.exit(1);
114
116
  }
115
- } else if (arg === "--interactive" || arg === "-i") {
117
+ } else if (arg === '--interactive' || arg === '-i') {
116
118
  interactive = true;
117
- } else if (arg === "--global") {
119
+ } else if (arg === '--global') {
118
120
  // --global installs skills into ~/.claude/skills (user-wide) instead of project-local
119
121
  passthrough.push(arg);
120
122
  } else {
@@ -125,19 +127,31 @@ function handlePull(args) {
125
127
  // Build the skills CLI invocation:
126
128
  // skills add <source> -a claude-code -a cursor [--skill <name> | --skill * -y]
127
129
  // See: https://github.com/vercel-labs/skills
128
- const cliArgs = ["add", source, ...AGENT_FLAGS];
130
+ const cliArgs = ['add', source, ...AGENT_FLAGS];
129
131
  if (skill_name) {
130
- cliArgs.push("--skill", skill_name);
132
+ cliArgs.push('--skill', skill_name);
131
133
  } else if (!interactive) {
132
134
  // Pull all skills and auto-confirm (-y / --yes) without interactive prompts
133
- cliArgs.push("--skill", "*", "-y");
135
+ cliArgs.push('--skill', '*', '-y');
134
136
  }
135
137
  cliArgs.push(...passthrough);
136
138
 
137
139
  console.log(`šŸ”„ Pulling skills from ${source}...`);
138
140
 
139
141
  runSkillsCli(cliArgs);
140
- console.log("\nāœ… Skills pulled successfully");
142
+ console.log('\nāœ… Skills pulled successfully');
143
+ }
144
+
145
+ /**
146
+ * Handle `dune skills list`
147
+ */
148
+ function handleList() {
149
+ try {
150
+ runSkillsCli(['list']);
151
+ } catch (error) {
152
+ console.error('āŒ Failed to list skills:', error instanceof Error ? error.message : String(error));
153
+ process.exit(1);
154
+ }
141
155
  }
142
156
 
143
157
  /**
@@ -151,21 +165,24 @@ export function handleSkillsCommand(args) {
151
165
  try {
152
166
  switch (subcommand) {
153
167
  case undefined:
154
- case "help":
155
- case "--help":
156
- case "-h":
168
+ case 'help':
169
+ case '--help':
170
+ case '-h':
157
171
  printHelp();
158
172
  break;
159
- case "pull":
173
+ case 'pull':
160
174
  handlePull(subArgs);
161
175
  break;
176
+ case 'list':
177
+ handleList();
178
+ break;
162
179
  default:
163
180
  console.error(`āŒ Unknown skills command: ${subcommand}`);
164
181
  printHelp();
165
182
  process.exit(1);
166
183
  }
167
184
  } catch (error) {
168
- console.error("āŒ Skills command failed:", error.message);
185
+ console.error('āŒ Skills command failed:', error.message);
169
186
  process.exit(1);
170
187
  }
171
188
  }
@@ -4,9 +4,8 @@
4
4
  * Provides functions for generating secure random strings and PKCE code challenges.
5
5
  */
6
6
 
7
- import crypto from "node:crypto";
7
+ import crypto from 'node:crypto';
8
8
 
9
- // biome-ignore lint/complexity/noStaticOnlyClass: Utility class pattern
10
9
  export class CryptoUtils {
11
10
  /**
12
11
  * Generate a cryptographically secure random string
@@ -16,10 +15,10 @@ export class CryptoUtils {
16
15
  static generateRandomString(length) {
17
16
  const bytes = crypto.randomBytes(length);
18
17
  return bytes
19
- .toString("base64")
20
- .replace(/\+/g, "-")
21
- .replace(/\//g, "_")
22
- .replace(/=/g, "")
18
+ .toString('base64')
19
+ .replace(/\+/g, '-')
20
+ .replace(/\//g, '_')
21
+ .replace(/=/g, '')
23
22
  .slice(0, length);
24
23
  }
25
24
 
@@ -29,7 +28,7 @@ export class CryptoUtils {
29
28
  * @returns {string} Base64url-encoded SHA256 hash of the verifier
30
29
  */
31
30
  static generateCodeChallenge(verifier) {
32
- const hash = crypto.createHash("sha256").update(verifier).digest();
33
- return hash.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
31
+ const hash = crypto.createHash('sha256').update(verifier).digest();
32
+ return hash.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
34
33
  }
35
34
  }
@@ -1,31 +1,28 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as _cognite_sdk from '@cognite/sdk';
2
+ import * as react from 'react';
3
+ import { ReactNode } from 'react';
3
4
  import { CogniteClient } from '@cognite/sdk';
4
- import React from 'react';
5
5
 
6
- declare const DuneAuthProviderContext: React.Context<{
6
+ interface DuneContextValue {
7
7
  sdk: CogniteClient;
8
8
  isLoading: boolean;
9
9
  error?: string;
10
- }>;
10
+ }
11
+ declare const DuneAuthProviderContext: react.Context<DuneContextValue>;
11
12
  interface DuneAuthProviderProps {
12
- children: React.ReactNode;
13
+ children: ReactNode;
13
14
  useIFrameAuthentication?: boolean;
14
15
  useLocalConfiguration?: {
15
16
  org: string;
16
17
  project: string;
17
18
  baseUrl: string;
18
19
  };
19
- loadingComponent?: React.ReactNode;
20
- errorComponent?: (error: string) => React.ReactNode;
20
+ loadingComponent?: ReactNode;
21
+ errorComponent?: (error: string) => ReactNode;
21
22
  }
22
23
  declare const DuneAuthProvider: ({ children, loadingComponent, errorComponent, }: DuneAuthProviderProps) => react_jsx_runtime.JSX.Element;
23
24
 
24
- declare const useDune: () => {
25
- sdk: _cognite_sdk.CogniteClient;
26
- isLoading: boolean;
27
- error?: string;
28
- };
25
+ declare const useDune: () => DuneContextValue;
29
26
 
30
27
  interface CDFConfig {
31
28
  project: string;
@@ -38,4 +35,4 @@ declare const getToken: (clientId: string, clientSecret: string) => Promise<any>
38
35
  declare const createCDFSDK: (config: CDFConfig) => Promise<CogniteClient>;
39
36
  declare const EMPTY_SDK: CogniteClient;
40
37
 
41
- export { type CDFConfig, DuneAuthProvider, DuneAuthProviderContext, type DuneAuthProviderProps, EMPTY_SDK, createCDFSDK, getToken, useDune };
38
+ export { type CDFConfig, DuneAuthProvider, DuneAuthProviderContext, type DuneAuthProviderProps, type DuneContextValue, EMPTY_SDK, createCDFSDK, getToken, useDune };
@@ -5,7 +5,7 @@ import {
5
5
  createCDFSDK,
6
6
  getToken,
7
7
  useDune
8
- } from "../chunk-VIBN7U5H.js";
8
+ } from "../chunk-53VTKDSC.js";
9
9
  export {
10
10
  DuneAuthProvider,
11
11
  DuneAuthProviderContext,
@@ -1,7 +1,6 @@
1
1
  // src/auth/dune-auth-provider.tsx
2
2
  import { CogniteClient as CogniteClient2 } from "@cognite/sdk";
3
- import { createContext, useEffect } from "react";
4
- import { useState } from "react";
3
+ import { createContext, useEffect, useState } from "react";
5
4
 
6
5
  // src/auth/utils.ts
7
6
  import { CogniteClient } from "@cognite/sdk";
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { CDFConfig, DuneAuthProvider, DuneAuthProviderContext, DuneAuthProviderProps, EMPTY_SDK, createCDFSDK, getToken, useDune } from './auth/index.js';
1
+ export { CDFConfig, DuneAuthProvider, DuneAuthProviderContext, DuneAuthProviderProps, DuneContextValue, EMPTY_SDK, createCDFSDK, getToken, useDune } from './auth/index.js';
2
2
  import 'react/jsx-runtime';
3
- import '@cognite/sdk';
4
3
  import 'react';
4
+ import '@cognite/sdk';
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  createCDFSDK,
6
6
  getToken,
7
7
  useDune
8
- } from "./chunk-VIBN7U5H.js";
8
+ } from "./chunk-53VTKDSC.js";
9
9
  export {
10
10
  DuneAuthProvider,
11
11
  DuneAuthProviderContext,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cognite/dune",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Build and deploy React apps to Cognite Data Fusion",
5
5
  "keywords": ["cognite", "dune", "cdf", "fusion", "react", "scaffold", "deploy"],
6
6
  "license": "Apache-2.0",
@@ -1,24 +1,25 @@
1
- import { CogniteClient } from "@cognite/sdk";
2
- import type React from "react";
3
- import { createContext, useEffect } from "react";
4
- import { useState } from "react";
5
- import { EMPTY_SDK, handleCredentialsResponse, requestCredentials } from "./utils";
1
+ import { CogniteClient } from '@cognite/sdk';
2
+ import { createContext, useEffect, useState, type ReactNode } from 'react';
6
3
 
7
- export const DuneAuthProviderContext = createContext<{
4
+ import { EMPTY_SDK, handleCredentialsResponse, requestCredentials } from './utils';
5
+
6
+ export interface DuneContextValue {
8
7
  sdk: CogniteClient;
9
8
  isLoading: boolean;
10
9
  error?: string;
11
- }>({
10
+ }
11
+
12
+ export const DuneAuthProviderContext = createContext<DuneContextValue>({
12
13
  sdk: EMPTY_SDK,
13
14
  isLoading: false,
14
15
  });
15
16
 
16
17
  export interface DuneAuthProviderProps {
17
- children: React.ReactNode;
18
+ children: ReactNode;
18
19
  useIFrameAuthentication?: boolean;
19
20
  useLocalConfiguration?: { org: string; project: string; baseUrl: string };
20
- loadingComponent?: React.ReactNode;
21
- errorComponent?: (error: string) => React.ReactNode;
21
+ loadingComponent?: ReactNode;
22
+ errorComponent?: (error: string) => ReactNode;
22
23
  }
23
24
 
24
25
  export const DuneAuthProvider = ({
@@ -50,7 +51,7 @@ export const FusionIframeAuthenticationInnerProvider = ({
50
51
  requestCredentials();
51
52
 
52
53
  const handleMessage = async (event: MessageEvent) => {
53
- console.log("šŸ” Handling message from Fusion");
54
+ console.log('šŸ” Handling message from Fusion');
54
55
 
55
56
  const credentials = handleCredentialsResponse(event);
56
57
 
@@ -60,7 +61,7 @@ export const FusionIframeAuthenticationInnerProvider = ({
60
61
 
61
62
  // Process credentials (initial or refresh)
62
63
  const sdk = new CogniteClient({
63
- appId: "dune-app",
64
+ appId: 'dune-app',
64
65
  project: credentials.project,
65
66
  baseUrl: credentials.baseUrl,
66
67
  oidcTokenProvider: async () => {
@@ -74,12 +75,12 @@ export const FusionIframeAuthenticationInnerProvider = ({
74
75
  setIsLoading(false);
75
76
  };
76
77
 
77
- console.log("šŸ” Adding message listener");
78
- window.addEventListener("message", handleMessage);
79
- return () => window.removeEventListener("message", handleMessage);
78
+ console.log('šŸ” Adding message listener');
79
+ window.addEventListener('message', handleMessage);
80
+ return () => window.removeEventListener('message', handleMessage);
80
81
  }, []);
81
82
 
82
- console.log("šŸ” CDFIframeAuthenticationInnerProvider", sdk, isLoading, error);
83
+ console.log('šŸ” CDFIframeAuthenticationInnerProvider', sdk, isLoading, error);
83
84
 
84
85
  if (error && errorComponent) {
85
86
  return <>{errorComponent(error)}</>;
package/src/auth/index.ts CHANGED
@@ -2,10 +2,10 @@
2
2
  export {
3
3
  DuneAuthProvider,
4
4
  DuneAuthProviderContext,
5
- } from "./dune-auth-provider";
6
- export { useDune } from "./use-dune";
7
- export { getToken, createCDFSDK, EMPTY_SDK } from "./utils";
5
+ } from './dune-auth-provider';
6
+ export { useDune } from './use-dune';
7
+ export { getToken, createCDFSDK, EMPTY_SDK } from './utils';
8
8
 
9
9
  // Type exports
10
- export type { CDFConfig } from "./utils";
11
- export type { DuneAuthProviderProps } from "./dune-auth-provider";
10
+ export type { CDFConfig } from './utils';
11
+ export type { DuneAuthProviderProps, DuneContextValue } from './dune-auth-provider';
@@ -1,11 +1,12 @@
1
- import { useContext } from "react";
2
- import { DuneAuthProviderContext } from "./dune-auth-provider";
1
+ import { useContext } from 'react';
3
2
 
4
- export const useDune = () => {
3
+ import { DuneAuthProviderContext, type DuneContextValue } from './dune-auth-provider';
4
+
5
+ export const useDune = (): DuneContextValue => {
5
6
  const context = useContext(DuneAuthProviderContext);
6
7
 
7
8
  if (!context) {
8
- throw new Error("useDune must be used within a DuneAuthProvider");
9
+ throw new Error('useDune must be used within a DuneAuthProvider');
9
10
  }
10
11
 
11
12
  return context;
package/src/auth/utils.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { CogniteClient } from "@cognite/sdk";
1
+ import { CogniteClient } from '@cognite/sdk';
2
2
 
3
3
  export const MESSAGE_TYPES = {
4
- APP_HOST_READY: "APP_HOST_READY",
5
- APP_READY: "APP_READY",
6
- CREDENTIALS: "CREDENTIALS",
7
- REQUEST_CREDENTIALS: "REQUEST_CREDENTIALS",
4
+ APP_HOST_READY: 'APP_HOST_READY',
5
+ APP_READY: 'APP_READY',
6
+ CREDENTIALS: 'CREDENTIALS',
7
+ REQUEST_CREDENTIALS: 'REQUEST_CREDENTIALS',
8
8
  } as const;
9
9
 
10
10
  export interface CDFConfig {
@@ -18,14 +18,14 @@ export interface CDFConfig {
18
18
  export const getToken = async (clientId: string, clientSecret: string) => {
19
19
  const header = `Basic ${btoa(`${clientId}:${clientSecret}`)}`;
20
20
 
21
- const response = await fetch("https://auth.cognite.com/oauth2/token", {
22
- method: "POST",
21
+ const response = await fetch('https://auth.cognite.com/oauth2/token', {
22
+ method: 'POST',
23
23
  headers: {
24
24
  Authorization: header,
25
- "Content-Type": "application/x-www-form-urlencoded",
25
+ 'Content-Type': 'application/x-www-form-urlencoded',
26
26
  },
27
27
  body: new URLSearchParams({
28
- grant_type: "client_credentials",
28
+ grant_type: 'client_credentials',
29
29
  }),
30
30
  });
31
31
 
@@ -34,11 +34,11 @@ export const getToken = async (clientId: string, clientSecret: string) => {
34
34
  };
35
35
 
36
36
  export const createCDFSDK = async (config: CDFConfig) => {
37
- const { project, baseUrl, clientId, clientSecret, appId = "cdf-authentication-package" } = config;
37
+ const { project, baseUrl, clientId, clientSecret, appId = 'cdf-authentication-package' } = config;
38
38
 
39
39
  if (!project || !baseUrl || !clientId || !clientSecret) {
40
40
  throw new Error(
41
- "Missing required configuration. Please provide: project, baseUrl, clientId, clientSecret"
41
+ 'Missing required configuration. Please provide: project, baseUrl, clientId, clientSecret'
42
42
  );
43
43
  }
44
44
 
@@ -56,9 +56,9 @@ export const createCDFSDK = async (config: CDFConfig) => {
56
56
  };
57
57
 
58
58
  export const EMPTY_SDK = new CogniteClient({
59
- appId: "cdf-authentication-package",
60
- project: "",
61
- oidcTokenProvider: async () => "",
59
+ appId: 'cdf-authentication-package',
60
+ project: '',
61
+ oidcTokenProvider: async () => '',
62
62
  });
63
63
 
64
64
  interface Credentials {
@@ -68,18 +68,18 @@ interface Credentials {
68
68
  }
69
69
 
70
70
  export const requestCredentials = () => {
71
- console.log("šŸ”‘ Requesting credentials from parent...");
71
+ console.log('šŸ”‘ Requesting credentials from parent...');
72
72
  if (window.parent && window.parent !== window) {
73
- window.parent.postMessage({ type: "REQUEST_CREDENTIALS" }, "*");
73
+ window.parent.postMessage({ type: 'REQUEST_CREDENTIALS' }, '*');
74
74
  }
75
75
  };
76
76
 
77
77
  export const handleCredentialsResponse = (event: MessageEvent) => {
78
78
  // Check if this is a credentials message (wrapped in type/credentials format)
79
- if (event.data?.type === "PROVIDE_CREDENTIALS" && event.data?.credentials) {
79
+ if (event.data?.type === 'PROVIDE_CREDENTIALS' && event.data?.credentials) {
80
80
  const creds = event.data.credentials;
81
81
  if (creds.token && creds.baseUrl && creds.project) {
82
- console.log("šŸŽ‰ useCredentials received credentials:", {
82
+ console.log('šŸŽ‰ useCredentials received credentials:', {
83
83
  hasToken: !!creds.token,
84
84
  tokenLength: creds.token?.length || 0,
85
85
  project: creds.project,
@@ -4,8 +4,9 @@
4
4
  * Handles deployment of packaged applications to CDF.
5
5
  */
6
6
 
7
- import fs from "node:fs";
8
- import type { CogniteClient } from "@cognite/sdk";
7
+ import fs from 'node:fs';
8
+
9
+ import type { CogniteClient } from '@cognite/sdk';
9
10
 
10
11
  export class CdfApplicationDeployer {
11
12
  private client: CogniteClient;
@@ -17,7 +18,7 @@ export class CdfApplicationDeployer {
17
18
  this.client = client;
18
19
  }
19
20
 
20
- private DATA_SET_EXTERNAL_ID = "published-custom-apps";
21
+ private DATA_SET_EXTERNAL_ID = 'published-custom-apps';
21
22
 
22
23
  /**
23
24
  * Validate that the required data set exists and is accessible
@@ -36,8 +37,8 @@ export class CdfApplicationDeployer {
36
37
  const created = await this.client.datasets.create([
37
38
  {
38
39
  externalId: this.DATA_SET_EXTERNAL_ID,
39
- name: "Published Custom Apps",
40
- description: "Published Custom Apps",
40
+ name: 'Published Custom Apps',
41
+ description: 'Published Custom Apps',
41
42
  writeProtected: false,
42
43
  },
43
44
  ]);
@@ -69,11 +70,11 @@ export class CdfApplicationDeployer {
69
70
  published = false
70
71
  ): Promise<void> {
71
72
  // Validate data set exists and get its ID
72
- console.log("šŸ” Validating data set access...");
73
+ console.log('šŸ” Validating data set access...');
73
74
  const dataSetId = await this.validateDataSet();
74
75
  console.log(`āœ… Data set '${this.DATA_SET_EXTERNAL_ID}' validated (ID: ${dataSetId})\n`);
75
76
 
76
- console.log("šŸ“ Creating file record...");
77
+ console.log('šŸ“ Creating file record...');
77
78
 
78
79
  const fileContent = fs.readFileSync(zipFilename);
79
80
  const metadata = {
@@ -88,7 +89,7 @@ export class CdfApplicationDeployer {
88
89
  {
89
90
  name: `${appExternalId}-${versionTag}.zip`,
90
91
  externalId: `${appExternalId}-${versionTag}`,
91
- directory: "/dune-apps",
92
+ directory: '/dune-apps',
92
93
  metadata: metadata,
93
94
  dataSetId: dataSetId,
94
95
  },
@@ -97,7 +98,7 @@ export class CdfApplicationDeployer {
97
98
  true // waitUntilAcknowledged
98
99
  );
99
100
 
100
- console.log("āœ… File record created");
101
+ console.log('āœ… File record created');
101
102
  }
102
103
 
103
104
  /**
@@ -117,7 +118,7 @@ export class CdfApplicationDeployer {
117
118
  zipFilename: string,
118
119
  published = false
119
120
  ): Promise<void> {
120
- console.log("\nšŸš€ Deploying application to CDF...\n");
121
+ console.log('\nšŸš€ Deploying application to CDF...\n');
121
122
 
122
123
  try {
123
124
  // Upload to Files API
@@ -130,7 +131,7 @@ export class CdfApplicationDeployer {
130
131
  published
131
132
  );
132
133
 
133
- console.log("\nāœ… Deployment successful!");
134
+ console.log('\nāœ… Deployment successful!');
134
135
  } catch (error: unknown) {
135
136
  const message = error instanceof Error ? error.message : String(error);
136
137
  throw new Error(`Deployment failed: ${message}`);
@@ -4,9 +4,10 @@
4
4
  * Handles packaging of build directories into deployment-ready zip files.
5
5
  */
6
6
 
7
- import fs from "node:fs";
8
- import path from "node:path";
9
- import archiver from "archiver";
7
+ import fs from 'node:fs';
8
+ import path from 'node:path';
9
+
10
+ import archiver from 'archiver';
10
11
 
11
12
  export class ApplicationPackager {
12
13
  private distPath: string;
@@ -14,7 +15,7 @@ export class ApplicationPackager {
14
15
  /**
15
16
  * @param {string} distDirectory - Build directory to package (can be relative or absolute)
16
17
  */
17
- constructor(distDirectory = "dist") {
18
+ constructor(distDirectory = 'dist') {
18
19
  // If distDirectory is already an absolute path, use it as-is
19
20
  // Otherwise, join it with the current working directory
20
21
  this.distPath = path.isAbsolute(distDirectory)
@@ -38,29 +39,29 @@ export class ApplicationPackager {
38
39
  * @param {boolean} verbose - Enable verbose logging
39
40
  * @returns {Promise<string>} Path to created zip file
40
41
  */
41
- async createZip(outputFilename = "app.zip", verbose = false): Promise<string> {
42
+ async createZip(outputFilename = 'app.zip', verbose = false): Promise<string> {
42
43
  this.validateBuildDirectory();
43
44
 
44
- console.log("šŸ“¦ Packaging application...");
45
+ console.log('šŸ“¦ Packaging application...');
45
46
 
46
47
  return new Promise((resolve, reject) => {
47
48
  const output = fs.createWriteStream(outputFilename);
48
- const archive = archiver("zip", {
49
+ const archive = archiver('zip', {
49
50
  zlib: { level: 9 }, // Maximum compression
50
51
  });
51
52
 
52
- output.on("close", () => {
53
+ output.on('close', () => {
53
54
  const sizeMB = (archive.pointer() / 1024 / 1024).toFixed(2);
54
55
  console.log(`āœ… App packaged: ${outputFilename} (${sizeMB} MB)`);
55
56
  resolve(outputFilename);
56
57
  });
57
58
 
58
- archive.on("error", (err: Error) => {
59
+ archive.on('error', (err: Error) => {
59
60
  reject(new Error(`Failed to create zip: ${err.message}`));
60
61
  });
61
62
 
62
63
  if (verbose) {
63
- archive.on("entry", (entry: archiver.EntryData) => {
64
+ archive.on('entry', (entry: archiver.EntryData) => {
64
65
  console.log(` šŸ“„ ${entry.name}`);
65
66
  });
66
67
  }
@@ -1,8 +1,9 @@
1
- import fs from "node:fs";
2
- import { CdfApplicationDeployer } from "./application-deployer";
3
- import { ApplicationPackager } from "./application-packager";
4
- import { getSdk } from "./get-sdk";
5
- import type { App, Deployment } from "./types";
1
+ import fs from 'node:fs';
2
+
3
+ import { CdfApplicationDeployer } from './application-deployer';
4
+ import { ApplicationPackager } from './application-packager';
5
+ import { getSdk } from './get-sdk';
6
+ import type { App, Deployment } from './types';
6
7
 
7
8
  export const deploy = async (deployment: Deployment, app: App, folder: string) => {
8
9
  // Step 1: Get an SDK instance
@@ -11,7 +12,7 @@ export const deploy = async (deployment: Deployment, app: App, folder: string) =
11
12
  // Step 2: Package application (from the dist subdirectory)
12
13
  const distPath = `${folder}/dist`;
13
14
  const packager = new ApplicationPackager(distPath);
14
- const zipFilename = await packager.createZip("app.zip", true);
15
+ const zipFilename = await packager.createZip('app.zip', true);
15
16
 
16
17
  // Step 3: Deploy to CDF
17
18
  const deployer = new CdfApplicationDeployer(sdk);