cognite-create 0.1.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/bin/index.js +145 -0
- package/package.json +17 -0
- package/templates/.cursor/mcp.json +11 -0
- package/templates/components.json +24 -0
- package/templates/globals.css +165 -0
package/bin/index.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require('node:child_process');
|
|
4
|
+
const fs = require('node:fs/promises');
|
|
5
|
+
const path = require('node:path');
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
const args = process.argv.slice(2);
|
|
9
|
+
|
|
10
|
+
if (args.length === 0 || args[0].startsWith('-')) {
|
|
11
|
+
console.error('Usage: cognite-create <project-name> [create-next-app options]');
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const projectDir = args[0];
|
|
16
|
+
const createArgs = ['create-next-app@latest', ...args];
|
|
17
|
+
await runCreateNextApp(createArgs);
|
|
18
|
+
await addCogniteTemplates(projectDir);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function runCreateNextApp(cliArgs) {
|
|
22
|
+
const command = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
23
|
+
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
const child = spawn(command, cliArgs, { stdio: 'inherit' });
|
|
26
|
+
|
|
27
|
+
child.on('error', reject);
|
|
28
|
+
child.on('close', (code) => {
|
|
29
|
+
if (code !== 0) {
|
|
30
|
+
const error = new Error(`create-next-app exited with code ${code}`);
|
|
31
|
+
error.exitCode = code;
|
|
32
|
+
return reject(error);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
resolve();
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function addCogniteTemplates(projectDir) {
|
|
41
|
+
const targetRoot = path.resolve(process.cwd(), projectDir);
|
|
42
|
+
const templateRoot = path.resolve(__dirname, '..', 'templates');
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
await fs.access(targetRoot);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
if (error.code === 'ENOENT') {
|
|
48
|
+
throw new Error(
|
|
49
|
+
`Expected to find the newly created project at "${projectDir}", but it was not found. ` +
|
|
50
|
+
'Check the create-next-app output for more details.'
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const filesToCopy = [
|
|
58
|
+
{
|
|
59
|
+
source: path.join(templateRoot, 'components.json'),
|
|
60
|
+
target: path.join(targetRoot, 'components.json'),
|
|
61
|
+
overwrite: false,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
source: path.join(templateRoot, '.cursor', 'mcp.json'),
|
|
65
|
+
target: path.join(targetRoot, '.cursor', 'mcp.json'),
|
|
66
|
+
overwrite: false,
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
const globalsCssTarget = await resolveGlobalsCssTarget(targetRoot);
|
|
71
|
+
filesToCopy.push({
|
|
72
|
+
source: path.join(templateRoot, 'globals.css'),
|
|
73
|
+
target: globalsCssTarget,
|
|
74
|
+
overwrite: true,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
for (const file of filesToCopy) {
|
|
78
|
+
if (file.overwrite) {
|
|
79
|
+
await copyFileWithOverwrite(file.source, file.target);
|
|
80
|
+
} else {
|
|
81
|
+
await copyFileIfMissing(file.source, file.target);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
console.log('\nCognite templates copied successfully.');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function copyFileIfMissing(source, target) {
|
|
89
|
+
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
await fs.access(target);
|
|
93
|
+
console.warn(`Skipped existing ${path.relative(process.cwd(), target)}`);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
if (error.code !== 'ENOENT') {
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
await fs.copyFile(source, target);
|
|
100
|
+
console.log(`Added ${path.relative(process.cwd(), target)}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function copyFileWithOverwrite(source, target) {
|
|
105
|
+
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
106
|
+
await fs.copyFile(source, target);
|
|
107
|
+
console.log(`Replaced ${path.relative(process.cwd(), target)}`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function resolveGlobalsCssTarget(targetRoot) {
|
|
111
|
+
const srcDirPath = path.join(targetRoot, 'src', 'app', 'globals.css');
|
|
112
|
+
const appDirPath = path.join(targetRoot, 'app', 'globals.css');
|
|
113
|
+
|
|
114
|
+
if (await fileExists(srcDirPath)) {
|
|
115
|
+
return srcDirPath;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (await fileExists(appDirPath)) {
|
|
119
|
+
return appDirPath;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return appDirPath;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async function fileExists(filePath) {
|
|
126
|
+
try {
|
|
127
|
+
await fs.access(filePath);
|
|
128
|
+
return true;
|
|
129
|
+
} catch (error) {
|
|
130
|
+
if (error.code === 'ENOENT') {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
main().catch((error) => {
|
|
139
|
+
if (error && typeof error.exitCode === 'number') {
|
|
140
|
+
process.exit(error.exitCode);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
144
|
+
process.exit(1);
|
|
145
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cognite-create",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Create a Next.js app preconfigured with Cognite defaults.",
|
|
5
|
+
"private": false,
|
|
6
|
+
"bin": {
|
|
7
|
+
"cognite-create": "./bin/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"templates"
|
|
12
|
+
],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=18.0.0"
|
|
15
|
+
},
|
|
16
|
+
"license": "UNLICENSED"
|
|
17
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema.json",
|
|
3
|
+
"style": "new-york",
|
|
4
|
+
"rsc": true,
|
|
5
|
+
"tsx": true,
|
|
6
|
+
"tailwind": {
|
|
7
|
+
"config": "",
|
|
8
|
+
"css": "src/app/globals.css",
|
|
9
|
+
"baseColor": "neutral",
|
|
10
|
+
"cssVariables": true,
|
|
11
|
+
"prefix": ""
|
|
12
|
+
},
|
|
13
|
+
"iconLibrary": "lucide",
|
|
14
|
+
"aliases": {
|
|
15
|
+
"components": "@/components",
|
|
16
|
+
"utils": "@/lib/utils",
|
|
17
|
+
"ui": "@/components/ui",
|
|
18
|
+
"lib": "@/lib",
|
|
19
|
+
"hooks": "@/hooks"
|
|
20
|
+
},
|
|
21
|
+
"registries": {
|
|
22
|
+
"@cognite": "http://localhost:3000/r/{registry}.json"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
2
|
+
@import "tw-animate-css";
|
|
3
|
+
|
|
4
|
+
@custom-variant dark (&:is(.dark *));
|
|
5
|
+
|
|
6
|
+
@theme inline {
|
|
7
|
+
--color-background: var(--background);
|
|
8
|
+
--color-foreground: var(--foreground);
|
|
9
|
+
--font-sans: var(--font-inter);
|
|
10
|
+
--font-mono: var(--font-inter);
|
|
11
|
+
--heading-1: var(--font-inter);
|
|
12
|
+
--heading-2: var(--font-inter);
|
|
13
|
+
--body-large: var(--font-inter);
|
|
14
|
+
--body-medium: var(--font-inter);
|
|
15
|
+
--body-small: var(--font-inter);
|
|
16
|
+
--color-sidebar-ring: var(--sidebar-ring);
|
|
17
|
+
--color-sidebar-border: var(--sidebar-border);
|
|
18
|
+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
19
|
+
--color-sidebar-accent: var(--sidebar-accent);
|
|
20
|
+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
21
|
+
--color-sidebar-primary: var(--sidebar-primary);
|
|
22
|
+
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
23
|
+
--color-sidebar: var(--sidebar);
|
|
24
|
+
--color-chart-5: var(--chart-5);
|
|
25
|
+
--color-chart-4: var(--chart-4);
|
|
26
|
+
--color-chart-3: var(--chart-3);
|
|
27
|
+
--color-chart-2: var(--chart-2);
|
|
28
|
+
--color-chart-1: var(--chart-1);
|
|
29
|
+
--color-ring: var(--ring);
|
|
30
|
+
--color-input: var(--input);
|
|
31
|
+
--color-border: var(--border);
|
|
32
|
+
--color-destructive: var(--destructive);
|
|
33
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
34
|
+
--color-accent: var(--accent);
|
|
35
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
36
|
+
--color-muted: var(--muted);
|
|
37
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
38
|
+
--color-secondary: var(--secondary);
|
|
39
|
+
--color-secondary-muted-default: var(--secondary-muted-default);
|
|
40
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
41
|
+
--color-primary: var(--primary);
|
|
42
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
43
|
+
--color-popover: var(--popover);
|
|
44
|
+
--color-card-foreground: var(--card-foreground);
|
|
45
|
+
--color-card: var(--card);
|
|
46
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
47
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
48
|
+
--radius-lg: var(--radius);
|
|
49
|
+
--radius-xl: calc(var(--radius) + 4px);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
:root {
|
|
53
|
+
--radius: 0.625rem;
|
|
54
|
+
--background: oklch(1 0 0);
|
|
55
|
+
--foreground: oklch(0.145 0 0);
|
|
56
|
+
--card: oklch(1 0 0);
|
|
57
|
+
--card-foreground: oklch(0.145 0 0);
|
|
58
|
+
--popover: oklch(1 0 0);
|
|
59
|
+
--popover-foreground: oklch(0.145 0 0);
|
|
60
|
+
--primary: oklch(0.205 0 0);
|
|
61
|
+
--primary-foreground: oklch(0.985 0 0);
|
|
62
|
+
--secondary: oklch(0.97 0 0);
|
|
63
|
+
--secondary-foreground: oklch(0.205 0 0);
|
|
64
|
+
--secondary-muted-default: #e4e4e7;
|
|
65
|
+
--muted: oklch(0.97 0 0);
|
|
66
|
+
--muted-foreground: oklch(0.556 0 0);
|
|
67
|
+
--accent: oklch(0.97 0 0);
|
|
68
|
+
--accent-foreground: oklch(0.205 0 0);
|
|
69
|
+
--destructive: oklch(0.577 0.245 27.325);
|
|
70
|
+
--border: oklch(0.922 0 0);
|
|
71
|
+
--input: oklch(0.922 0 0);
|
|
72
|
+
--ring: oklch(0.708 0 0);
|
|
73
|
+
--chart-1: oklch(0.646 0.222 41.116);
|
|
74
|
+
--chart-2: oklch(0.6 0.118 184.704);
|
|
75
|
+
--chart-3: oklch(0.398 0.07 227.392);
|
|
76
|
+
--chart-4: oklch(0.828 0.189 84.429);
|
|
77
|
+
--chart-5: oklch(0.769 0.188 70.08);
|
|
78
|
+
--sidebar: oklch(0.985 0 0);
|
|
79
|
+
--sidebar-foreground: oklch(0.145 0 0);
|
|
80
|
+
--sidebar-primary: oklch(0.205 0 0);
|
|
81
|
+
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
82
|
+
--sidebar-accent: oklch(0.97 0 0);
|
|
83
|
+
--sidebar-accent-foreground: oklch(0.205 0 0);
|
|
84
|
+
--sidebar-border: oklch(0.922 0 0);
|
|
85
|
+
--sidebar-ring: oklch(0.708 0 0);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.dark {
|
|
89
|
+
--background: oklch(0.145 0 0);
|
|
90
|
+
--foreground: oklch(0.985 0 0);
|
|
91
|
+
--card: oklch(0.205 0 0);
|
|
92
|
+
--card-foreground: oklch(0.985 0 0);
|
|
93
|
+
--popover: oklch(0.205 0 0);
|
|
94
|
+
--popover-foreground: oklch(0.985 0 0);
|
|
95
|
+
--primary: oklch(0.922 0 0);
|
|
96
|
+
--primary-foreground: oklch(0.205 0 0);
|
|
97
|
+
--secondary: oklch(0.269 0 0);
|
|
98
|
+
--secondary-foreground: oklch(0.985 0 0);
|
|
99
|
+
--secondary-muted-default: #e4e4e7;
|
|
100
|
+
--muted: oklch(0.269 0 0);
|
|
101
|
+
--muted-foreground: oklch(0.708 0 0);
|
|
102
|
+
--accent: oklch(0.269 0 0);
|
|
103
|
+
--accent-foreground: oklch(0.985 0 0);
|
|
104
|
+
--destructive: oklch(0.704 0.191 22.216);
|
|
105
|
+
--border: oklch(1 0 0 / 10%);
|
|
106
|
+
--input: oklch(1 0 0 / 15%);
|
|
107
|
+
--ring: oklch(0.556 0 0);
|
|
108
|
+
--chart-1: oklch(0.488 0.243 264.376);
|
|
109
|
+
--chart-2: oklch(0.696 0.17 162.48);
|
|
110
|
+
--chart-3: oklch(0.769 0.188 70.08);
|
|
111
|
+
--chart-4: oklch(0.627 0.265 303.9);
|
|
112
|
+
--chart-5: oklch(0.645 0.246 16.439);
|
|
113
|
+
--sidebar: oklch(0.205 0 0);
|
|
114
|
+
--sidebar-foreground: oklch(0.985 0 0);
|
|
115
|
+
--sidebar-primary: oklch(0.488 0.243 264.376);
|
|
116
|
+
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
117
|
+
--sidebar-accent: oklch(0.269 0 0);
|
|
118
|
+
--sidebar-accent-foreground: oklch(0.985 0 0);
|
|
119
|
+
--sidebar-border: oklch(1 0 0 / 10%);
|
|
120
|
+
--sidebar-ring: oklch(0.556 0 0);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@layer base {
|
|
124
|
+
* {
|
|
125
|
+
@apply border-border outline-ring/50;
|
|
126
|
+
}
|
|
127
|
+
body {
|
|
128
|
+
@apply bg-background text-foreground;
|
|
129
|
+
}
|
|
130
|
+
h1 {
|
|
131
|
+
font-family: var(--heading-1);
|
|
132
|
+
font-weight: 700;
|
|
133
|
+
font-size: 36px;
|
|
134
|
+
line-height: 44px;
|
|
135
|
+
letter-spacing: -0.59px;
|
|
136
|
+
}
|
|
137
|
+
h2 {
|
|
138
|
+
font-family: var(--heading-2);
|
|
139
|
+
font-weight: 700;
|
|
140
|
+
font-size: 28px;
|
|
141
|
+
line-height: 32px;
|
|
142
|
+
letter-spacing: -0.59px;
|
|
143
|
+
}
|
|
144
|
+
.body-large {
|
|
145
|
+
font-family: var(--body-large);
|
|
146
|
+
font-weight: 400;
|
|
147
|
+
font-size: 16px;
|
|
148
|
+
line-height: 20px;
|
|
149
|
+
letter-spacing: -0.17px;
|
|
150
|
+
}
|
|
151
|
+
.body-medium {
|
|
152
|
+
font-family: var(--body-medium);
|
|
153
|
+
font-weight: 400;
|
|
154
|
+
font-size: 14px;
|
|
155
|
+
line-height: 20px;
|
|
156
|
+
letter-spacing: -0.08px;
|
|
157
|
+
}
|
|
158
|
+
.body-small {
|
|
159
|
+
font-family: var(--body-small);
|
|
160
|
+
font-weight: 400;
|
|
161
|
+
font-size: 12px;
|
|
162
|
+
line-height: 16px;
|
|
163
|
+
letter-spacing: -0.04px;
|
|
164
|
+
}
|
|
165
|
+
}
|