create-dovite 1.0.4 → 2.0.1
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/index.js +20 -159
- package/package.json +6 -2
- package/src/files.js +72 -0
- package/src/prompts.js +49 -0
- package/src/setup.js +106 -0
- package/{template → templates/react-js}/public/manifest.json +12 -12
- package/templates/react-js/src/App.jsx +13 -0
- package/templates/react-js/src/index.css +1 -0
- package/templates/react-ts/public/manifest.json +12 -0
- package/templates/react-ts/public/thumbnail.png +0 -0
- package/templates/react-ts/src/API/currentUserContext.tsx +66 -0
- package/templates/react-ts/src/API/dataApi.ts +338 -0
- package/templates/react-ts/src/API/domoAPI.ts +355 -0
- package/templates/react-ts/src/App.tsx +13 -0
- package/templates/react-ts/src/index.css +1 -0
- package/templates/react-ts/tsconfig.app.json +31 -0
- package/templates/react-ts/tsconfig.json +17 -0
- package/templates/react-ts/vite.config.ts +47 -0
- package/template/src/App.css +0 -41
- package/template/src/App.jsx +0 -40
- package/template/src/assets/DOMO.svg +0 -9
- package/template/src/index.css +0 -132
- /package/{template → templates/react-js}/jsconfig.json +0 -0
- /package/{template → templates/react-js}/public/thumbnail.png +0 -0
- /package/{template → templates/react-js}/src/API/currentUserContext.jsx +0 -0
- /package/{template → templates/react-js}/src/API/dataApi.js +0 -0
- /package/{template → templates/react-js}/src/API/domoAPI.js +0 -0
- /package/{template → templates/react-js}/vite.config.js +0 -0
package/index.js
CHANGED
|
@@ -1,174 +1,35 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const {
|
|
3
|
-
const
|
|
4
|
-
|
|
2
|
+
const { getProjectDetails } = require("./src/prompts");
|
|
3
|
+
const {
|
|
4
|
+
createViteProject,
|
|
5
|
+
updatePackageJson,
|
|
6
|
+
installDependencies,
|
|
7
|
+
initializeShadcn,
|
|
8
|
+
initializeGit,
|
|
9
|
+
} = require("./src/setup");
|
|
10
|
+
const { copyTemplateFiles, updateManifest } = require("./src/files");
|
|
5
11
|
|
|
6
12
|
async function main() {
|
|
7
13
|
try {
|
|
8
|
-
const projectName =
|
|
9
|
-
|
|
10
|
-
if (!projectName) {
|
|
11
|
-
console.error("Please specify a project name");
|
|
12
|
-
process.exit(1);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
console.log(`Creating new project: ${projectName}`);
|
|
16
|
-
|
|
17
|
-
// Create Vite project
|
|
18
|
-
execSync(
|
|
19
|
-
`yarn create vite ${projectName} --template react --no-interactive`,
|
|
20
|
-
{
|
|
21
|
-
stdio: "inherit",
|
|
22
|
-
}
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
// Move into project directory
|
|
26
|
-
process.chdir(projectName);
|
|
27
|
-
|
|
28
|
-
// Fix package name
|
|
29
|
-
console.log("Updating package name...");
|
|
30
|
-
const packageJson = JSON.parse(fs.readFileSync("package.json", "utf8"));
|
|
31
|
-
packageJson.name = projectName;
|
|
32
|
-
fs.writeFileSync("package.json", JSON.stringify(packageJson, null, 2));
|
|
33
|
-
|
|
34
|
-
// Install initial dependencies
|
|
35
|
-
console.log("Installing dependencies...");
|
|
36
|
-
execSync("yarn", { stdio: "inherit" });
|
|
37
|
-
|
|
38
|
-
// Install all required dependencies
|
|
39
|
-
console.log("Installing additional dependencies...");
|
|
40
|
-
execSync(
|
|
41
|
-
"yarn add tailwindcss @tailwindcss/vite @domoinc/ryuu-proxy ryuu.js tailwind-merge react-icons",
|
|
42
|
-
{ stdio: "inherit" }
|
|
43
|
-
);
|
|
44
|
-
execSync("yarn add -D @types/node", { stdio: "inherit" });
|
|
45
|
-
|
|
46
|
-
// Update src/index.css
|
|
47
|
-
fs.writeFileSync("src/index.css", `@import "tailwindcss";`);
|
|
48
|
-
|
|
49
|
-
// Copy template files if they exist
|
|
50
|
-
const templateDir = path.join(__dirname, "template");
|
|
51
|
-
if (fs.existsSync(templateDir)) {
|
|
52
|
-
console.log("Copying template files...");
|
|
53
|
-
// This is a simple implementation - you might want a more robust solution
|
|
54
|
-
// that preserves directory structure
|
|
55
|
-
const copyRecursive = (src, dest) => {
|
|
56
|
-
if (fs.statSync(src).isDirectory()) {
|
|
57
|
-
if (!fs.existsSync(dest)) {
|
|
58
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
59
|
-
}
|
|
60
|
-
const files = fs.readdirSync(src);
|
|
61
|
-
for (const file of files) {
|
|
62
|
-
copyRecursive(path.join(src, file), path.join(dest, file));
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
fs.copyFileSync(src, dest);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
copyRecursive(templateDir, "./");
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Update manifest.js if it exists in public folder
|
|
72
|
-
const publicDir = path.join(process.cwd(), "public");
|
|
73
|
-
const manifestPath = path.join(publicDir, "manifest.js");
|
|
74
|
-
|
|
75
|
-
if (fs.existsSync(manifestPath)) {
|
|
76
|
-
console.log("Updating manifest.js with project name...");
|
|
77
|
-
let manifestContent = fs.readFileSync(manifestPath, "utf8");
|
|
78
|
-
|
|
79
|
-
// Replace name field in manifest.js with the project name
|
|
80
|
-
// This assumes a standard format like: name: "OldName",
|
|
81
|
-
manifestContent = manifestContent.replace(
|
|
82
|
-
/name:\s*["']([^"']*)["']/g,
|
|
83
|
-
`name: "${projectName}"`
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
fs.writeFileSync(manifestPath, manifestContent);
|
|
87
|
-
} else {
|
|
88
|
-
// If manifest.js doesn't exist yet, create public directory and a basic manifest file
|
|
89
|
-
if (!fs.existsSync(publicDir)) {
|
|
90
|
-
fs.mkdirSync(publicDir, { recursive: true });
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
console.log("Creating manifest.js with project name...");
|
|
94
|
-
const basicManifest = `export default {
|
|
95
|
-
name: "${projectName}",
|
|
96
|
-
version: "1.0.0",
|
|
97
|
-
description: "${projectName} application"
|
|
98
|
-
};
|
|
99
|
-
`;
|
|
100
|
-
fs.writeFileSync(manifestPath, basicManifest);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Update package.json with latest versions
|
|
104
|
-
console.log("Updating package.json...");
|
|
105
|
-
const updatedPackageJson = JSON.parse(
|
|
106
|
-
fs.readFileSync("package.json", "utf8")
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
// Update scripts
|
|
110
|
-
updatedPackageJson.scripts = {
|
|
111
|
-
dev: "vite",
|
|
112
|
-
build: "vite build",
|
|
113
|
-
lint: "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
|
|
114
|
-
preview: "vite preview",
|
|
115
|
-
upload: "yarn run build && cd dist && domo publish && cd ..", //only line need to be added
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
fs.writeFileSync(
|
|
119
|
-
"package.json",
|
|
120
|
-
JSON.stringify(updatedPackageJson, null, 2)
|
|
14
|
+
const { projectName, templateType } = await getProjectDetails(
|
|
15
|
+
process.argv[2]
|
|
121
16
|
);
|
|
122
17
|
|
|
123
|
-
|
|
124
|
-
console.log("Initializing shadcn...");
|
|
125
|
-
try {
|
|
126
|
-
execSync("npx shadcn@latest init", { stdio: "inherit" });
|
|
127
|
-
} catch (error) {
|
|
128
|
-
console.log(
|
|
129
|
-
'Note: You may need to run "npx shadcn@latest init" manually if initialization failed.'
|
|
130
|
-
);
|
|
131
|
-
}
|
|
18
|
+
createViteProject(projectName, templateType);
|
|
132
19
|
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
|
|
20
|
+
// Operations that modify files inside the project
|
|
21
|
+
// We pass projectName so they can resolve paths correctly relative to CWD
|
|
22
|
+
updatePackageJson(projectName, templateType);
|
|
136
23
|
|
|
137
|
-
|
|
138
|
-
// const componentsJsonPath = path.join(process.cwd(), "components.json");
|
|
139
|
-
// if (fs.existsSync(componentsJsonPath)) {
|
|
140
|
-
// console.log("Updating components.json...");
|
|
141
|
-
// try {
|
|
142
|
-
// const componentsJson = JSON.parse(
|
|
143
|
-
// fs.readFileSync(componentsJsonPath, "utf8")
|
|
144
|
-
// );
|
|
24
|
+
installDependencies(projectName);
|
|
145
25
|
|
|
146
|
-
|
|
147
|
-
// if (componentsJson.aliases) {
|
|
148
|
-
// componentsJson.aliases.utils = "/src/lib/utils";
|
|
149
|
-
// }
|
|
26
|
+
copyTemplateFiles(projectName, templateType);
|
|
150
27
|
|
|
151
|
-
|
|
152
|
-
// componentsJsonPath,
|
|
153
|
-
// JSON.stringify(componentsJson, null, 2)
|
|
154
|
-
// );
|
|
155
|
-
// console.log("Successfully updated components.json");
|
|
156
|
-
// } catch (error) {
|
|
157
|
-
// console.error("Error updating components.json:", error.message);
|
|
158
|
-
// }
|
|
159
|
-
// } else {
|
|
160
|
-
// console.log(
|
|
161
|
-
// "Warning: components.json not found. Make sure shadcn initialization completed successfully."
|
|
162
|
-
// );
|
|
163
|
-
// }
|
|
164
|
-
execSync("npx shadcn@latest add button", { stdio: "inherit" });
|
|
28
|
+
updateManifest(projectName);
|
|
165
29
|
|
|
166
|
-
|
|
30
|
+
initializeShadcn(projectName);
|
|
167
31
|
|
|
168
|
-
|
|
169
|
-
execSync("git add .", { stdio: "inherit" });
|
|
170
|
-
execSync(`git commit -m "first commit"`, { stdio: "inherit" });
|
|
171
|
-
execSync("git checkout -b main", { stdio: "inherit" });
|
|
32
|
+
initializeGit(projectName);
|
|
172
33
|
|
|
173
34
|
console.log(`
|
|
174
35
|
Project ${projectName} created successfully!
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-dovite",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
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
|
-
"
|
|
10
|
+
"templates",
|
|
11
|
+
"src",
|
|
11
12
|
"index.js"
|
|
12
13
|
],
|
|
13
14
|
"keywords": [
|
|
@@ -24,5 +25,8 @@
|
|
|
24
25
|
"repository": {
|
|
25
26
|
"type": "git",
|
|
26
27
|
"url": "https://github.com/Ajay-Balu/create-dovite"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"prompts": "^2.4.2"
|
|
27
31
|
}
|
|
28
32
|
}
|
package/src/files.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
module.exports = { copyTemplateFiles, updateManifest };
|
package/src/prompts.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
],
|
|
26
|
+
initial: 0,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
if (questions.length > 0) {
|
|
30
|
+
const response = await prompts(questions, {
|
|
31
|
+
onCancel: () => {
|
|
32
|
+
console.log("Operation cancelled");
|
|
33
|
+
process.exit(0);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (!projectName) projectName = response.projectName || projectName;
|
|
38
|
+
templateType = response.template;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!projectName) {
|
|
42
|
+
console.error("Please specify a project name");
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return { projectName, templateType };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = { getProjectDetails };
|
package/src/setup.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
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
|
+
const viteTemplate = templateType === "react-ts" ? "react-ts" : "react";
|
|
11
|
+
execSync(
|
|
12
|
+
`yarn create vite ${projectName} --template ${viteTemplate} --no-interactive`,
|
|
13
|
+
{
|
|
14
|
+
stdio: "inherit",
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function updatePackageJson(projectName, templateType) {
|
|
20
|
+
console.log("Updating package name and scripts...");
|
|
21
|
+
const packageJsonPath = path.join(projectName, "package.json");
|
|
22
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
23
|
+
|
|
24
|
+
packageJson.name = projectName;
|
|
25
|
+
|
|
26
|
+
packageJson.scripts = {
|
|
27
|
+
...packageJson.scripts,
|
|
28
|
+
dev: "vite",
|
|
29
|
+
build: templateType === "react-ts" ? "tsc -b && vite build" : "vite build",
|
|
30
|
+
lint: "eslint .",
|
|
31
|
+
preview: "vite preview",
|
|
32
|
+
upload: "yarn run build && cd dist && domo publish && cd ..",
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function installDependencies(projectName) {
|
|
39
|
+
console.log("Installing dependencies...");
|
|
40
|
+
// We need to run this inside the project directory
|
|
41
|
+
// But since we are passing projectName, we can use cwd option or chdir before calling this.
|
|
42
|
+
// However, the original script chdir'd into the project.
|
|
43
|
+
// Let's assume the caller will handle chdir or we pass cwd.
|
|
44
|
+
// To keep it simple and consistent with original flow, let's assume we are IN the project dir
|
|
45
|
+
// OR we pass the cwd to execSync.
|
|
46
|
+
// The original script did `process.chdir(projectName)`.
|
|
47
|
+
|
|
48
|
+
// Let's stick to the original flow where we chdir in the main script,
|
|
49
|
+
// OR we can make these functions robust.
|
|
50
|
+
// For now, let's assume we are inside the directory for these commands to work easily
|
|
51
|
+
// without passing cwd everywhere, BUT `updatePackageJson` used `path.join`.
|
|
52
|
+
// Let's make `updatePackageJson` work with relative path, and these commands too.
|
|
53
|
+
|
|
54
|
+
// Actually, `yarn` needs to run in the project dir.
|
|
55
|
+
|
|
56
|
+
const options = { stdio: "inherit", cwd: projectName };
|
|
57
|
+
|
|
58
|
+
execSync("yarn", options);
|
|
59
|
+
|
|
60
|
+
console.log("Installing additional dependencies...");
|
|
61
|
+
execSync(
|
|
62
|
+
"yarn add tailwindcss @tailwindcss/vite @domoinc/ryuu-proxy ryuu.js tailwind-merge react-icons",
|
|
63
|
+
options
|
|
64
|
+
);
|
|
65
|
+
execSync("yarn add -D @types/node", options);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function initializeShadcn(projectName) {
|
|
69
|
+
console.log("Initializing shadcn...");
|
|
70
|
+
const options = { stdio: "inherit", cwd: projectName };
|
|
71
|
+
try {
|
|
72
|
+
execSync("npx shadcn@latest init", options);
|
|
73
|
+
|
|
74
|
+
// Install new dependencies after shadcn (it might add some)
|
|
75
|
+
// The original script ran yarn again.
|
|
76
|
+
console.log("Installing final dependencies...");
|
|
77
|
+
execSync("yarn", options);
|
|
78
|
+
|
|
79
|
+
execSync("npx shadcn@latest add button", options);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.log(
|
|
82
|
+
'Note: You may need to run "npx shadcn@latest init" manually if initialization failed.'
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function initializeGit(projectName) {
|
|
88
|
+
console.log("Initializing git");
|
|
89
|
+
const options = { stdio: "inherit", cwd: projectName };
|
|
90
|
+
try {
|
|
91
|
+
execSync("git init", options);
|
|
92
|
+
execSync("git add .", options);
|
|
93
|
+
execSync(`git commit -m "first commit"`, options);
|
|
94
|
+
execSync("git checkout -b main", options);
|
|
95
|
+
} catch (e) {
|
|
96
|
+
console.log("Git initialization failed or skipped.");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
module.exports = {
|
|
101
|
+
createViteProject,
|
|
102
|
+
updatePackageJson,
|
|
103
|
+
installDependencies,
|
|
104
|
+
initializeShadcn,
|
|
105
|
+
initializeGit,
|
|
106
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "project-name",
|
|
3
|
-
"version": "
|
|
4
|
-
"size": {
|
|
5
|
-
"width": 3,
|
|
6
|
-
"height": 3
|
|
7
|
-
},
|
|
8
|
-
"mapping": [],
|
|
9
|
-
"collections": [],
|
|
10
|
-
"workflowMapping": [],
|
|
11
|
-
"packagesMapping": []
|
|
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,13 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { Button } from "./components/ui/button";
|
|
3
|
+
import "./App.css";
|
|
4
|
+
function App() {
|
|
5
|
+
const [count, setCount] = useState(0);
|
|
6
|
+
return (
|
|
7
|
+
<div className="App">
|
|
8
|
+
<Button onClick={() => setCount(count + 1)}>Count: {count}</Button>
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default App;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
Binary file
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
import { createContext, useState, useEffect, ReactNode } from "react";
|
|
4
|
+
import DomoApi from "./domoAPI";
|
|
5
|
+
|
|
6
|
+
export interface UserContextType {
|
|
7
|
+
currentUser: string;
|
|
8
|
+
currentUserId: string;
|
|
9
|
+
avatarKey: string;
|
|
10
|
+
customer: string;
|
|
11
|
+
host: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const UserContext = createContext<UserContextType | undefined>(
|
|
15
|
+
undefined
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export const UserProvider = ({ children }: { children: ReactNode }) => {
|
|
19
|
+
const [currentUser, setCurrentUser] = useState<string>("");
|
|
20
|
+
const [currentUserId, setCurrentUserId] = useState<string>("");
|
|
21
|
+
const [avatarKey, setAvatarKey] = useState<string>("");
|
|
22
|
+
const [customer, setCustomer] = useState<string>("");
|
|
23
|
+
const [host, setHost] = useState<string>("");
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
let isUserFetched = false;
|
|
27
|
+
|
|
28
|
+
DomoApi.GetCurrentUser().then((data: any) => {
|
|
29
|
+
// console.log("User Data",data);
|
|
30
|
+
|
|
31
|
+
if (!isUserFetched) {
|
|
32
|
+
const userId = data?.userId;
|
|
33
|
+
const displayName = data?.displayName;
|
|
34
|
+
const avatarKey = data?.avatarKey;
|
|
35
|
+
const customer = data?.customer;
|
|
36
|
+
const host = data?.host;
|
|
37
|
+
|
|
38
|
+
setCurrentUser(displayName || "");
|
|
39
|
+
setCurrentUserId(userId || "");
|
|
40
|
+
setAvatarKey(avatarKey || "");
|
|
41
|
+
setCustomer(customer || "");
|
|
42
|
+
setHost(host || "");
|
|
43
|
+
|
|
44
|
+
isUserFetched = true;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return () => {
|
|
49
|
+
isUserFetched = true;
|
|
50
|
+
};
|
|
51
|
+
}, []);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<UserContext.Provider
|
|
55
|
+
value={{
|
|
56
|
+
currentUser,
|
|
57
|
+
currentUserId,
|
|
58
|
+
avatarKey,
|
|
59
|
+
customer,
|
|
60
|
+
host,
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
{children}
|
|
64
|
+
</UserContext.Provider>
|
|
65
|
+
);
|
|
66
|
+
};
|