cognite-create 0.1.5 → 0.1.6

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 CHANGED
@@ -1,7 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
3
4
  const { spawn } = require('node:child_process');
5
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
4
6
  const fs = require('node:fs/promises');
7
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
5
8
  const path = require('node:path');
6
9
 
7
10
  async function main() {
@@ -54,18 +57,21 @@ async function addCogniteTemplates(projectDir) {
54
57
  throw error;
55
58
  }
56
59
 
57
- const appDirectory = await resolveAppDirectory(targetRoot);
60
+ const srcDirectory = path.join(targetRoot, 'src');
58
61
  const templateFiles = await collectTemplateFiles(templateRoot);
59
62
 
63
+ await fs.mkdir(srcDirectory, { recursive: true });
64
+
60
65
  for (const relativePath of templateFiles) {
61
66
  const normalizedPath = normalizeRelativePath(relativePath);
62
67
  const source = path.join(templateRoot, relativePath);
63
68
 
64
69
  const pathSegments = normalizedPath.split('/');
65
70
 
66
- if (pathSegments[0] === 'app') {
67
- const target = path.join(appDirectory, ...pathSegments.slice(1));
68
- const isGlobalsCss = pathSegments.length === 2 && pathSegments[1] === 'globals.css';
71
+ if (pathSegments[0] === 'app' || pathSegments[0] === 'lib') {
72
+ const target = path.join(srcDirectory, ...pathSegments);
73
+ const isGlobalsCss =
74
+ pathSegments[0] === 'app' && pathSegments.length === 2 && pathSegments[1] === 'globals.css';
69
75
 
70
76
  if (isGlobalsCss) {
71
77
  await copyFileWithOverwrite(source, target);
@@ -105,19 +111,6 @@ async function copyFileWithOverwrite(source, target) {
105
111
  console.log(`Replaced ${path.relative(process.cwd(), target)}`);
106
112
  }
107
113
 
108
- async function fileExists(filePath) {
109
- try {
110
- await fs.access(filePath);
111
- return true;
112
- } catch (error) {
113
- if (error.code === 'ENOENT') {
114
- return false;
115
- }
116
-
117
- throw error;
118
- }
119
- }
120
-
121
114
  async function collectTemplateFiles(rootDir) {
122
115
  const files = [];
123
116
 
@@ -147,16 +140,6 @@ function normalizeRelativePath(relativePath) {
147
140
  return relativePath.split(path.sep).join('/');
148
141
  }
149
142
 
150
- async function resolveAppDirectory(targetRoot) {
151
- const srcAppDir = path.join(targetRoot, 'src', 'app');
152
-
153
- if (await fileExists(srcAppDir)) {
154
- return srcAppDir;
155
- }
156
-
157
- return path.join(targetRoot, 'app');
158
- }
159
-
160
143
  main().catch((error) => {
161
144
  if (error && typeof error.exitCode === 'number') {
162
145
  process.exit(error.exitCode);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cognite-create",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Create a Next.js app preconfigured with Cognite defaults.",
5
5
  "private": false,
6
6
  "bin": {
@@ -4,4 +4,4 @@ globs:
4
4
  alwaysApply: true
5
5
  ---
6
6
 
7
- Where possible check the Cognite ShadCN registry for components before making your own.
7
+ Use the ShadCN MCP server to check the Cognite registry for components before making your own.