cognite-create 0.2.33 → 0.2.34

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 (2) hide show
  1. package/bin/index.js +13 -21
  2. package/package.json +1 -1
package/bin/index.js CHANGED
@@ -126,47 +126,39 @@ async function addCogniteTemplates(projectDir) {
126
126
 
127
127
  if (pathSegments[0] === "app" || pathSegments[0] === "lib") {
128
128
  const target = path.join(srcDirectory, ...pathSegments);
129
- const isGlobalsCss =
130
- pathSegments[0] === "app" &&
131
- pathSegments.length === 2 &&
132
- pathSegments[1] === "globals.css";
133
-
134
- if (isGlobalsCss) {
135
- await copyFileWithOverwrite(source, target);
136
- } else {
137
- await copyFileIfMissing(source, target);
138
- }
139
-
129
+ // Overwrite template files in src/app and src/lib
130
+ await copyFileWithOverwrite(source, target);
140
131
  continue;
141
132
  }
142
133
 
134
+ // Overwrite root-level configuration files
143
135
  const target = path.join(targetRoot, relativePath);
144
- await copyFileIfMissing(source, target);
136
+ await copyFileWithOverwrite(source, target);
145
137
  }
146
138
 
147
139
  console.log("\nCognite templates copied successfully.");
148
140
  }
149
141
 
150
- async function copyFileIfMissing(source, target) {
142
+ async function copyFileWithOverwrite(source, target) {
151
143
  await fs.mkdir(path.dirname(target), { recursive: true });
152
144
 
145
+ let fileExists = false;
153
146
  try {
154
147
  await fs.access(target);
155
- console.warn(`Skipped existing ${path.relative(process.cwd(), target)}`);
148
+ fileExists = true;
156
149
  } catch (error) {
157
150
  if (error.code !== "ENOENT") {
158
151
  throw error;
159
152
  }
160
-
161
- await fs.copyFile(source, target);
162
- console.log(`Added ${path.relative(process.cwd(), target)}`);
163
153
  }
164
- }
165
154
 
166
- async function copyFileWithOverwrite(source, target) {
167
- await fs.mkdir(path.dirname(target), { recursive: true });
168
155
  await fs.copyFile(source, target);
169
- console.log(`Replaced ${path.relative(process.cwd(), target)}`);
156
+
157
+ if (fileExists) {
158
+ console.log(`Replaced ${path.relative(process.cwd(), target)}`);
159
+ } else {
160
+ console.log(`Added ${path.relative(process.cwd(), target)}`);
161
+ }
170
162
  }
171
163
 
172
164
  async function collectTemplateFiles(rootDir) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cognite-create",
3
- "version": "0.2.33",
3
+ "version": "0.2.34",
4
4
  "description": "Create a Next.js app preconfigured with Cognite defaults.",
5
5
  "bin": {
6
6
  "cognite-create": "./bin/index.js"