@telemetryos/cli 1.4.1 → 1.4.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @telemetryos/cli
2
2
 
3
+ ## 1.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - improve ux of init command
8
+ - Updated dependencies
9
+ - @telemetryos/development-application-host-ui@1.4.2
10
+
3
11
  ## 1.4.1
4
12
 
5
13
  ### Patch Changes
@@ -4,15 +4,14 @@ import inquirer from 'inquirer';
4
4
  import path from 'path';
5
5
  export const initCommand = new Command('init')
6
6
  .description('Initializes a new telemetryOS application')
7
- .option('-n, --name <string>', 'The name of the application', '')
8
- .option('-d, --description <string>', 'The description of the application', 'A telemetryOS application')
7
+ .option('-d, --description <string>', 'The description of the application', '')
9
8
  .option('-a, --author <string>', 'The author of the application', '')
10
9
  .option('-v, --version <string>', 'The version of the application', '0.1.0')
11
10
  .option('-t, --template <string>', 'The template to use (vite-react-typescript)', '')
12
- .argument('[project-path]', 'Path to create the new telemetry application project. Defaults to a folder current working directory with the same name as your project', '')
11
+ .argument('[project-name]', 'The name of the application', '')
13
12
  .action(handleInitCommand);
14
- async function handleInitCommand(projectPath, options) {
15
- let name = options.name;
13
+ async function handleInitCommand(projectName, options) {
14
+ let name = projectName;
16
15
  let description = options.description;
17
16
  let author = options.author;
18
17
  let version = options.version;
@@ -30,7 +29,7 @@ async function handleInitCommand(projectPath, options) {
30
29
  type: 'input',
31
30
  name: 'description',
32
31
  message: 'What is the description of your application?',
33
- default: ''
32
+ default: 'A telemetryOS application'
34
33
  });
35
34
  if (!author)
36
35
  questions.push({
@@ -60,11 +59,16 @@ async function handleInitCommand(projectPath, options) {
60
59
  const answers = await inquirer.prompt(questions);
61
60
  if (answers.name)
62
61
  name = answers.name;
62
+ if (answers.version)
63
+ version = answers.version;
64
+ if (answers.description)
65
+ description = answers.description;
66
+ if (answers.author)
67
+ author = answers.author;
63
68
  if (answers.template)
64
69
  template = answers.template;
65
70
  }
66
- if (!projectPath)
67
- projectPath = path.join(process.cwd(), name);
71
+ const projectPath = path.join(process.cwd(), name);
68
72
  await generateApplication({
69
73
  name,
70
74
  description,
@@ -1,6 +1,7 @@
1
+ import { spawn } from "child_process";
1
2
  import fs from "fs/promises";
2
3
  import path from "path";
3
- const ignoredTelemplateFiles = [
4
+ const ignoredTemplateFiles = [
4
5
  '.DS_Store',
5
6
  'thumbs.db',
6
7
  'node_modules',
@@ -13,15 +14,56 @@ export async function generateApplication(options) {
13
14
  await fs.mkdir(projectPath, { recursive: true });
14
15
  await copyDir(path.join(templatesDir, template), projectPath, {
15
16
  name,
17
+ version,
16
18
  description,
17
19
  author,
18
- version
19
20
  }, progressFn);
21
+ // Install latest versions of @telemetryos/sdk and @telemetryos/cli
22
+ console.log('\nInstalling dependencies...');
23
+ await installPackages(projectPath);
24
+ }
25
+ async function installPackages(projectPath) {
26
+ // Install SDK as a regular dependency
27
+ await new Promise((resolve, reject) => {
28
+ const sdkInstall = spawn('pnpm', ['add', '@telemetryos/sdk'], {
29
+ cwd: projectPath,
30
+ stdio: 'inherit'
31
+ });
32
+ sdkInstall.on('close', (code) => {
33
+ if (code === 0) {
34
+ resolve();
35
+ }
36
+ else {
37
+ reject(new Error(`pnpm add @telemetryos/sdk failed with code ${code}`));
38
+ }
39
+ });
40
+ sdkInstall.on('error', (error) => {
41
+ reject(error);
42
+ });
43
+ });
44
+ // Install CLI as a dev dependency
45
+ await new Promise((resolve, reject) => {
46
+ const cliInstall = spawn('pnpm', ['add', '-D', '@telemetryos/cli'], {
47
+ cwd: projectPath,
48
+ stdio: 'inherit'
49
+ });
50
+ cliInstall.on('close', (code) => {
51
+ if (code === 0) {
52
+ resolve();
53
+ }
54
+ else {
55
+ reject(new Error(`pnpm add -D @telemetryos/cli failed with code ${code}`));
56
+ }
57
+ });
58
+ cliInstall.on('error', (error) => {
59
+ reject(error);
60
+ });
61
+ });
20
62
  }
21
63
  async function copyDir(source, destination, replacements, progressFn) {
22
64
  const dirListing = await fs.readdir(source);
23
65
  for (const dirEntry of dirListing) {
24
- if (ignoredTelemplateFiles.includes(dirEntry))
66
+ if (ignoredTemplateFiles.includes(dirEntry))
25
67
  continue;
26
68
  const sourcePath = path.join(source, dirEntry);
27
69
  const destinationPath = path.join(destination, dirEntry);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telemetryos/cli",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "The official TelemetryOS application CLI package. Use it to build applications that run on the TelemetryOS platform",
5
5
  "type": "module",
6
6
  "bin": {
@@ -25,7 +25,7 @@
25
25
  "license": "",
26
26
  "repository": "github:TelemetryTV/Application-API",
27
27
  "dependencies": {
28
- "@telemetryos/development-application-host-ui": "^1.4.1",
28
+ "@telemetryos/development-application-host-ui": "^1.4.2",
29
29
  "@types/serve-handler": "^6.1.4",
30
30
  "commander": "^14.0.0",
31
31
  "inquirer": "^12.9.6",
@@ -2,19 +2,18 @@
2
2
  "name": "{{name}}",
3
3
  "version": "{{version}}",
4
4
  "description": "{{description}}",
5
+ "author": "{{author}}",
5
6
  "scripts": {
6
7
  "dev": "tos serve",
7
8
  "build": "tsc && vite build"
8
9
  },
9
10
  "dependencies": {
10
- "@telemetryos/sdk": "1.0.1",
11
11
  "react": "^19.1.1",
12
12
  "react-dom": "^19.1.1",
13
13
  "react-router": "^7.9.1"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@rollup/plugin-typescript": "^12.1.2",
17
- "@telemetryos/cli": "1.0.1",
18
17
  "@types/node": "^22.15.3",
19
18
  "@types/react": "^19.1.12",
20
19
  "@types/react-dom": "^19.1.9",