create-dovite 2.0.0 → 2.2.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/README.md CHANGED
@@ -1,20 +1,28 @@
1
1
  # create-dovite
2
2
 
3
- Vite template featuring Tailwind(v4), ShadCN, and DOMO integration.
3
+ <!-- a detailed description of the package with all the features -->
4
4
 
5
- > **Note:** This package requires yarn and the DOMO CLI to be installed before use.
5
+ **create-dovite** is a CLI tool designed to jumpstart the development of Domo Custom Apps. It provides a modern developer experience by combining the speed of **Vite** with the utility-first approach of **Tailwind CSS**. This starter kit comes pre-integrated with **shadcn/ui** for accessible components and includes built-in configurations for the **Domo Integrations**, ensuring a smooth transition from local development to production.
6
+
7
+ # Features
8
+
9
+ - ⚡️ Vite for fast development
10
+ - ⚛️ React and Vue support
11
+ - 📘 TypeScript and JavaScript support
12
+ - 🎨 Tailwind CSS for styling
13
+ - 🎯 shadcn/ui components
14
+ - 🔄 DOMO integration
15
+ - 📦 Preconfigured build setup
6
16
 
7
17
  ## Prerequisites
8
18
 
19
+ > **Note:** This package requires yarn and the DOMO CLI to be installed before use.
20
+
9
21
  ```bash
10
- # Install yarn if you don't have it
11
- npm install -g yarn
22
+ # Install yarn and DOMO CLI if you don't have them
23
+ npm install -g yarn ryuu
12
24
  ```
13
25
 
14
- # For DOMO CLI installation, refer to:
15
-
16
- [DOMO CLI](https://developer.domo.com/portal/6hlzv1hinkq19-setup-and-installation)
17
-
18
26
  ## Usage
19
27
 
20
28
  ```bash
@@ -25,19 +33,15 @@ yarn create dovite my-app
25
33
  npx create-dovite my-app
26
34
  ```
27
35
 
28
- ## Features
29
-
30
- - ⚡️ Vite for fast development
31
- - 🎨 Tailwind CSS for styling
32
- - 🎯 shadcn/ui components
33
- - 🔄 DOMO integration
34
- - 📦 Preconfigured build setup
35
-
36
36
  ## Requirements
37
37
 
38
38
  - Node.js 16.x or higher
39
39
  - npm or yarn
40
40
 
41
+ ## For DOMO CLI installation, refer to:
42
+
43
+ [DOMO CLI](https://developer.domo.com/portal/6hlzv1hinkq19-setup-and-installation)
44
+
41
45
  ## Inspirations
42
46
 
43
47
  - [DOMO Starter Kits](https://developer.domo.com/portal/u8w475o2245yp-starter-kits)
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  const { getProjectDetails } = require("./src/prompts");
3
3
  const {
4
4
  createViteProject,
@@ -7,7 +7,11 @@ const {
7
7
  initializeShadcn,
8
8
  initializeGit,
9
9
  } = require("./src/setup");
10
- const { copyTemplateFiles, updateManifest } = require("./src/files");
10
+ const {
11
+ copyTemplateFiles,
12
+ updateManifest,
13
+ cleanupViteDefaults,
14
+ } = require("./src/files");
11
15
 
12
16
  async function main() {
13
17
  try {
@@ -21,13 +25,15 @@ async function main() {
21
25
  // We pass projectName so they can resolve paths correctly relative to CWD
22
26
  updatePackageJson(projectName, templateType);
23
27
 
24
- installDependencies(projectName);
28
+ installDependencies(projectName, templateType);
25
29
 
26
30
  copyTemplateFiles(projectName, templateType);
27
31
 
32
+ cleanupViteDefaults(projectName, templateType);
33
+
28
34
  updateManifest(projectName);
29
35
 
30
- initializeShadcn(projectName);
36
+ initializeShadcn(projectName, templateType);
31
37
 
32
38
  initializeGit(projectName);
33
39
 
package/package.json CHANGED
@@ -1,13 +1,17 @@
1
1
  {
2
2
  "name": "create-dovite",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Vite template featuring Tailwind (v4), ShadCN (Canary), and DOMO integration.",
5
5
  "main": "index.js",
6
6
  "bin": {
7
7
  "create-dovite": "index.js"
8
8
  },
9
9
  "files": [
10
- "template",
10
+ "templates/react-js",
11
+ "templates/react-ts",
12
+ "templates/index.jsx",
13
+ "templates/index.css",
14
+ "src",
11
15
  "index.js"
12
16
  ],
13
17
  "keywords": [
@@ -23,7 +27,7 @@
23
27
  "license": "MIT",
24
28
  "repository": {
25
29
  "type": "git",
26
- "url": "https://github.com/Ajay-Balu/create-dovite"
30
+ "url": "git+https://github.com/Ajay-Balu/create-dovite.git"
27
31
  },
28
32
  "dependencies": {
29
33
  "prompts": "^2.4.2"
package/src/files.js ADDED
@@ -0,0 +1,111 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ function copyTemplateFiles(projectName, templateType) {
5
+ // __dirname is .../src
6
+ // templates are in .../templates
7
+ const templateDir = path.join(__dirname, "..", "templates", templateType);
8
+ const destDir = projectName; // Relative to CWD
9
+
10
+ if (fs.existsSync(templateDir)) {
11
+ console.log(`Copying ${templateType} template files...`);
12
+ const copyRecursive = (src, dest) => {
13
+ if (fs.statSync(src).isDirectory()) {
14
+ if (!fs.existsSync(dest)) {
15
+ fs.mkdirSync(dest, { recursive: true });
16
+ }
17
+ const files = fs.readdirSync(src);
18
+ for (const file of files) {
19
+ copyRecursive(path.join(src, file), path.join(dest, file));
20
+ }
21
+ } else {
22
+ fs.copyFileSync(src, dest);
23
+ }
24
+ };
25
+ copyRecursive(templateDir, destDir);
26
+ } else {
27
+ console.warn(`Template directory not found: ${templateDir}`);
28
+ }
29
+ }
30
+
31
+ function updateManifest(projectName) {
32
+ const publicDir = path.join(projectName, "public");
33
+ const manifestJsPath = path.join(publicDir, "manifest.js");
34
+ const manifestJsonPath = path.join(publicDir, "manifest.json");
35
+
36
+ if (fs.existsSync(manifestJsPath)) {
37
+ // Legacy/JS template handling
38
+ console.log("Updating manifest.js with project name...");
39
+ let manifestContent = fs.readFileSync(manifestJsPath, "utf8");
40
+ manifestContent = manifestContent.replace(
41
+ /name:\s*["']([^"']*)["']/g,
42
+ `name: "${projectName}"`
43
+ );
44
+ fs.writeFileSync(manifestJsPath, manifestContent);
45
+ } else if (fs.existsSync(manifestJsonPath)) {
46
+ // TS/JSON template handling
47
+ console.log("Updating manifest.json with project name...");
48
+ const manifestContent = JSON.parse(
49
+ fs.readFileSync(manifestJsonPath, "utf8")
50
+ );
51
+ manifestContent.name = projectName;
52
+ fs.writeFileSync(
53
+ manifestJsonPath,
54
+ JSON.stringify(manifestContent, null, 2)
55
+ );
56
+ } else {
57
+ // Create if missing (fallback)
58
+ if (!fs.existsSync(publicDir)) {
59
+ fs.mkdirSync(publicDir, { recursive: true });
60
+ }
61
+ // Default to JSON for new setup
62
+ console.log("Creating manifest.json with project name...");
63
+ const basicManifest = {
64
+ name: projectName,
65
+ version: "1.0.0",
66
+ description: `${projectName} application`,
67
+ };
68
+ fs.writeFileSync(manifestJsonPath, JSON.stringify(basicManifest, null, 2));
69
+ }
70
+ }
71
+
72
+ function cleanupViteDefaults(projectName, templateType) {
73
+ const isVue = templateType === "vue-js" || templateType === "vue-ts";
74
+
75
+ if (isVue) {
76
+ // Clean up default style.css created by Vite Vue template
77
+ // Remove body/#app styles that conflict with our landing page
78
+ const styleCssPath = path.join(projectName, "src", "style.css");
79
+ if (fs.existsSync(styleCssPath)) {
80
+ console.log("Cleaning up default style.css...");
81
+ let content = fs.readFileSync(styleCssPath, "utf8");
82
+
83
+ // Remove body styles block
84
+ content = content.replace(
85
+ /body\s*\{[^}]*display:\s*flex[^}]*place-items:\s*center[^}]*\}/gs,
86
+ ""
87
+ );
88
+
89
+ // Remove #app styles block
90
+ content = content.replace(
91
+ /#app\s*\{[^}]*max-width:\s*1280px[^}]*\}/gs,
92
+ ""
93
+ );
94
+
95
+ // Clean up extra whitespace
96
+ content = content.replace(/\n{3,}/g, "\n\n").trim();
97
+
98
+ // Write back the cleaned content (or empty string if nothing left)
99
+ fs.writeFileSync(styleCssPath, content + "\n");
100
+ }
101
+ }
102
+
103
+ // Remove App.css if it exists (created by Vite React template)
104
+ const appCssPath = path.join(projectName, "src", "App.css");
105
+ if (fs.existsSync(appCssPath)) {
106
+ console.log("Removing default App.css...");
107
+ fs.unlinkSync(appCssPath);
108
+ }
109
+ }
110
+
111
+ module.exports = { copyTemplateFiles, updateManifest, cleanupViteDefaults };
package/src/prompts.js ADDED
@@ -0,0 +1,52 @@
1
+ const prompts = require("prompts");
2
+
3
+ async function getProjectDetails(initialProjectName) {
4
+ let projectName = initialProjectName;
5
+ let templateType = "react-js"; // default
6
+
7
+ const questions = [];
8
+
9
+ if (!projectName) {
10
+ questions.push({
11
+ type: "text",
12
+ name: "projectName",
13
+ message: "Project name:",
14
+ initial: "my-dovite-app",
15
+ });
16
+ }
17
+
18
+ questions.push({
19
+ type: "select",
20
+ name: "template",
21
+ message: "Select a template:",
22
+ choices: [
23
+ { title: "React JavaScript", value: "react-js" },
24
+ { title: "React TypeScript", value: "react-ts" },
25
+ // Vue templates coming soon in a future release
26
+ // { title: "Vue JavaScript", value: "vue-js" },
27
+ // { title: "Vue TypeScript", value: "vue-ts" },
28
+ ],
29
+ initial: 0,
30
+ });
31
+
32
+ if (questions.length > 0) {
33
+ const response = await prompts(questions, {
34
+ onCancel: () => {
35
+ console.log("Operation cancelled");
36
+ process.exit(0);
37
+ },
38
+ });
39
+
40
+ if (!projectName) projectName = response.projectName || projectName;
41
+ templateType = response.template;
42
+ }
43
+
44
+ if (!projectName) {
45
+ console.error("Please specify a project name");
46
+ process.exit(1);
47
+ }
48
+
49
+ return { projectName, templateType };
50
+ }
51
+
52
+ module.exports = { getProjectDetails };
package/src/setup.js ADDED
@@ -0,0 +1,129 @@
1
+ const { execSync } = require("child_process");
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+
5
+ function createViteProject(projectName, templateType) {
6
+ console.log(
7
+ `Creating new project: ${projectName} with template ${templateType}`
8
+ );
9
+
10
+ // Map our template types to Vite's template names
11
+ const viteTemplateMap = {
12
+ "react-js": "react",
13
+ "react-ts": "react-ts",
14
+ "vue-js": "vue",
15
+ "vue-ts": "vue-ts",
16
+ };
17
+
18
+ const viteTemplate = viteTemplateMap[templateType] || "react";
19
+ execSync(
20
+ `yarn create vite ${projectName} --template ${viteTemplate} --no-interactive`,
21
+ {
22
+ stdio: "inherit",
23
+ }
24
+ );
25
+ }
26
+
27
+ function updatePackageJson(projectName, templateType) {
28
+ console.log("Updating package name and scripts...");
29
+ const packageJsonPath = path.join(projectName, "package.json");
30
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
31
+
32
+ packageJson.name = projectName;
33
+
34
+ // TypeScript templates need tsc build step
35
+ const isTypeScript = templateType === "react-ts" || templateType === "vue-ts";
36
+ const buildCommand = isTypeScript ? "vue-tsc -b && vite build" : "vite build";
37
+ // React-ts uses tsc, Vue-ts uses vue-tsc
38
+ const tsBuildCommand =
39
+ templateType === "react-ts" ? "tsc -b && vite build" : buildCommand;
40
+
41
+ packageJson.scripts = {
42
+ ...packageJson.scripts,
43
+ dev: "vite",
44
+ build: isTypeScript
45
+ ? templateType === "react-ts"
46
+ ? "tsc -b && vite build"
47
+ : "vue-tsc -b && vite build"
48
+ : "vite build",
49
+ lint: "eslint .",
50
+ preview: "vite preview",
51
+ upload: "yarn run build && cd dist && domo publish && cd ..",
52
+ };
53
+
54
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
55
+ }
56
+
57
+ function installDependencies(projectName, templateType) {
58
+ console.log("Installing dependencies...");
59
+ const options = { stdio: "inherit", cwd: projectName };
60
+ const isVue = templateType === "vue-js" || templateType === "vue-ts";
61
+
62
+ execSync("yarn", options);
63
+
64
+ console.log("Installing additional dependencies...");
65
+
66
+ // Common dependencies for all templates
67
+ const commonDeps =
68
+ "tailwindcss @tailwindcss/vite @domoinc/ryuu-proxy ryuu.js tailwind-merge";
69
+
70
+ if (isVue) {
71
+ // Vue-specific dependencies
72
+ execSync(`yarn add ${commonDeps}`, options);
73
+ } else {
74
+ // React-specific dependencies
75
+ execSync(`yarn add ${commonDeps} react-icons`, options);
76
+ }
77
+
78
+ execSync("yarn add -D @types/node", options);
79
+ }
80
+
81
+ function initializeShadcn(projectName, templateType) {
82
+ console.log("Initializing shadcn...");
83
+ const options = { stdio: "inherit", cwd: projectName };
84
+ const isVue = templateType === "vue-js" || templateType === "vue-ts";
85
+
86
+ try {
87
+ if (isVue) {
88
+ // Shadcn-vue uses a different initialization
89
+ execSync("npx shadcn-vue@latest init", options);
90
+ console.log("Installing final dependencies...");
91
+ execSync("yarn", options);
92
+ execSync("npx shadcn-vue@latest add button", options);
93
+ } else {
94
+ // React uses standard shadcn
95
+ execSync("npx shadcn@latest init", options);
96
+ console.log("Installing final dependencies...");
97
+ execSync("yarn", options);
98
+ execSync("npx shadcn@latest add button", options);
99
+ }
100
+ } catch (error) {
101
+ const shadcnCmd = isVue
102
+ ? "npx shadcn-vue@latest init"
103
+ : "npx shadcn@latest init";
104
+ console.log(
105
+ `Note: You may need to run "${shadcnCmd}" manually if initialization failed.`
106
+ );
107
+ }
108
+ }
109
+
110
+ function initializeGit(projectName) {
111
+ console.log("Initializing git");
112
+ const options = { stdio: "inherit", cwd: projectName };
113
+ try {
114
+ execSync("git init", options);
115
+ execSync("git add .", options);
116
+ execSync(`git commit -m "first commit"`, options);
117
+ execSync("git checkout -b main", options);
118
+ } catch (e) {
119
+ console.log("Git initialization failed or skipped.");
120
+ }
121
+ }
122
+
123
+ module.exports = {
124
+ createViteProject,
125
+ updatePackageJson,
126
+ installDependencies,
127
+ initializeShadcn,
128
+ initializeGit,
129
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "compilerOptions": {
3
+ "paths": {
4
+ "@/*": ["./src/*"]
5
+ }
6
+ }
7
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "project-name",
3
+ "version": "0.0.1",
4
+ "size": {
5
+ "width": 3,
6
+ "height": 3
7
+ },
8
+ "mapping": [],
9
+ "collections": [],
10
+ "workflowMapping": [],
11
+ "packagesMapping": []
12
+ }
@@ -0,0 +1,56 @@
1
+ /* eslint-disable react/prop-types */
2
+ import { createContext, useState, useEffect } from "react";
3
+ import DomoApi from "./DomoAPI";
4
+
5
+ export const UserContext = createContext();
6
+
7
+ export const UserProvider = ({ children }) => {
8
+ const [currentUser, setCurrentUser] = useState("");
9
+ const [currentUserId, setCurrentUserId] = useState("");
10
+ const [avatarKey, setAvatarKey] = useState("");
11
+ const [customer, setCustomer] = useState("");
12
+ const [host, setHost] = useState("");
13
+
14
+ useEffect(() => {
15
+ let isUserFetched = false;
16
+
17
+ DomoApi.GetCurrentUser().then((data) => {
18
+ // console.log("User Data",data);
19
+
20
+ if (!isUserFetched) {
21
+ const userId = data?.userId;
22
+ const displayName = data?.displayName;
23
+ const avatarKey = data?.avatarKey;
24
+ const customer=data?.customer;
25
+ const host=data?.host;
26
+
27
+ setCurrentUser(displayName || "");
28
+ setCurrentUserId(userId || "");
29
+ setAvatarKey(avatarKey || "");
30
+ setCustomer(customer || "");
31
+ setHost(host || "");
32
+
33
+
34
+ isUserFetched = true;
35
+ }
36
+ });
37
+
38
+ return () => {
39
+ isUserFetched = true;
40
+ };
41
+ }, []);
42
+
43
+ return (
44
+ <UserContext.Provider
45
+ value={{
46
+ currentUser,
47
+ currentUserId,
48
+ avatarKey,
49
+ customer,
50
+ host
51
+ }}
52
+ >
53
+ {children}
54
+ </UserContext.Provider>
55
+ );
56
+ };