@intend-it/cli 1.1.3 → 1.1.4

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/dist/index.js +31 -7
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -175,7 +175,7 @@ async function initCommand(args) {
175
175
  text: warn(error2.message)
176
176
  });
177
177
  }
178
- const typesPath = join2(directory, "src", "types.ts");
178
+ const typesPath = join2(srcDir, "types.ts");
179
179
  if (!existsSync2(typesPath)) {
180
180
  const typesContent = `export interface User {
181
181
  name: string;
@@ -183,11 +183,11 @@ async function initCommand(args) {
183
183
  createdAt: Date;
184
184
  }`;
185
185
  writeFileSync2(typesPath, typesContent, "utf-8");
186
- console.log(bullet(`${dim("src/types.ts")} ${dim("(typescript definition)")}`));
186
+ console.log(bullet(`${dim("src/intents/types.ts")} ${dim("(typescript definition)")}`));
187
187
  }
188
188
  const examplePath = join2(srcDir, "example.intent");
189
189
  if (!existsSync2(examplePath)) {
190
- const exampleContent = `import { User } from "../types";
190
+ const exampleContent = `import { User } from "./types";
191
191
 
192
192
  export intent CreateUser(name: string) -> User {
193
193
  step "Generate a random ID" => const id
@@ -226,8 +226,8 @@ out/
226
226
  }
227
227
 
228
228
  // src/commands/build.ts
229
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, writeFileSync as writeFileSync3, readFileSync as readFileSync2 } from "fs";
230
- import { join as join3, resolve as resolve3, basename } from "path";
229
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, writeFileSync as writeFileSync3, readFileSync as readFileSync2, copyFileSync } from "fs";
230
+ import { join as join3, resolve as resolve3, dirname, basename } from "path";
231
231
  import { AICodeGenerator, FileSystemCAS, computeHash, OllamaProvider } from "@intend-it/core";
232
232
  import * as readline from "readline";
233
233
  import { parseToAST } from "@intend-it/parser";
@@ -249,6 +249,26 @@ function findIntentFiles(dir, fileList = []) {
249
249
  });
250
250
  return fileList;
251
251
  }
252
+ function copyResources(src, dest) {
253
+ if (!existsSync3(src))
254
+ return;
255
+ if (!existsSync3(dest))
256
+ mkdirSync2(dest, { recursive: true });
257
+ const entries = readdirSync(src, { withFileTypes: true });
258
+ for (const entry of entries) {
259
+ const srcPath = join3(src, entry.name);
260
+ const destPath = join3(dest, entry.name);
261
+ if (entry.isDirectory()) {
262
+ if (entry.name !== "node_modules" && entry.name !== ".git") {
263
+ copyResources(srcPath, destPath);
264
+ }
265
+ } else if (entry.isFile()) {
266
+ if (entry.name.endsWith(".ts") && !entry.name.endsWith(".d.ts")) {
267
+ copyFileSync(srcPath, destPath);
268
+ }
269
+ }
270
+ }
271
+ }
252
272
  async function buildCommand(options) {
253
273
  const config = loadConfig(options.config);
254
274
  if (options.output)
@@ -378,14 +398,18 @@ async function buildCommand(options) {
378
398
  if (!existsSync3(outDir)) {
379
399
  mkdirSync2(outDir, { recursive: true });
380
400
  }
401
+ copyResources(sourceDir, outDir);
381
402
  newline();
382
403
  console.log(heading("Compiling"));
383
404
  for (const file of files) {
384
405
  if (!fileData.has(file))
385
406
  continue;
386
407
  const relativePath = file.substring(sourceDir.length + 1);
387
- const fileName = basename(file, ".intent");
388
- const outFile = join3(outDir, `${fileName}.ts`);
408
+ const outFile = join3(outDir, relativePath.replace(/\.intent$/, ".ts"));
409
+ const outDirForFile = dirname(outFile);
410
+ if (!existsSync3(outDirForFile)) {
411
+ mkdirSync2(outDirForFile, { recursive: true });
412
+ }
389
413
  const fileSpinner = spinner(`${relativePath}`).start();
390
414
  const fileStart = Date.now();
391
415
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intend-it/cli",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "CLI for the Intend programming language",
5
5
  "type": "module",
6
6
  "bin": {
@@ -29,8 +29,8 @@
29
29
  ],
30
30
  "license": "MIT",
31
31
  "dependencies": {
32
- "@intend-it/parser": "^1.1.3",
33
- "@intend-it/core": "^2.0.3",
32
+ "@intend-it/parser": "^1.1.4",
33
+ "@intend-it/core": "^2.0.4",
34
34
  "picocolors": "^1.1.1",
35
35
  "ora": "^8.1.1"
36
36
  },