create-nube-app 0.0.2 → 0.0.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.
package/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # create-nube-app <a href="https://npmjs.com/package/create-nube-app"><img src="https://img.shields.io/npm/v/create-nube-app" alt="npm package"></a>
2
+
3
+ **CLI to quickly create NubeSDK applications.**
4
+
5
+ ## About
6
+
7
+ `create-nube-app` is a command-line tool that allows you to create new NubeSDK applications with an optimized initial configuration. This tool automates the project setup process, including:
8
+
9
+ - Recommended directory structure
10
+ - TypeScript configuration
11
+ - Bundler configuration (tsup)
12
+ - Required dependencies
13
+ - Basic code examples
14
+
15
+ ## Installation
16
+
17
+ With NPM:
18
+
19
+ ```sh
20
+ npm create nube-app
21
+ ```
22
+
23
+ With Yarn:
24
+
25
+ ```sh
26
+ yarn create nube-app
27
+ ```
28
+ With PNPM:
29
+
30
+ ```sh
31
+ pnpm create nube-app
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ After running the command, you'll be guided through an interactive process that allows you to:
37
+
38
+ 1. What is the project's name?
39
+ 2. Select a template:
40
+
41
+ ### Usage Example
42
+
43
+ ```
44
+ $ npm create nube-app
45
+ What is the project's name?
46
+ Select a template:
47
+ Minimal
48
+ ❯ Minimal with UI
49
+ Minimal with UI in JSX
50
+ ```
51
+
52
+ ## Project Structure
53
+
54
+ After creation, your project will have the following structure:
55
+
56
+ ```
57
+ my-nube-app/
58
+ ├── src/
59
+ │ └── main.ts
60
+ ├── package.json
61
+ ├── tsconfig.json
62
+ ├── tsup.config.js
63
+ └── biome.json
64
+ ```
65
+
66
+ ## Available Scripts
67
+
68
+ The created project includes the following scripts:
69
+
70
+ - `npm run build` → Builds the project using tsup
71
+
72
+ ## Official Documentation
73
+
74
+ For more details about NubeSDK and how to build apps, check out our **official documentation**:
75
+
76
+ [**NubeSDK Documentation**](https://dev.tiendanube.com/docs/applications/nube-sdk/overview)
77
+
78
+ ## Support
79
+
80
+ - **Questions?** Use [GitHub Issues](https://github.com/TiendaNube/nube-sdk/issues).
81
+ - **Found a bug?** Open an issue with a reproducible example.
82
+
83
+ ---
84
+
85
+ © [Tiendanube / Nuvemshop](https://www.tiendanube.com), 2025. All rights reserved.
package/dist/index.js ADDED
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import * as prompts from "@clack/prompts";
5
+ import fs from "fs-extra";
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
+ function toSlug(text) {
8
+ return text.toLowerCase().replace(/\s+/g, "-");
9
+ }
10
+ function pkgFromUserAgent(userAgent) {
11
+ if (!userAgent) return void 0;
12
+ const pkgSpec = userAgent.split(" ")[0];
13
+ const pkgSpecArr = pkgSpec.split("/");
14
+ return {
15
+ name: pkgSpecArr[0],
16
+ version: pkgSpecArr[1]
17
+ };
18
+ }
19
+ function isEmpty(path2) {
20
+ const files = fs.readdirSync(path2);
21
+ return files.length === 0 || files.length === 1 && files[0] === ".git";
22
+ }
23
+ async function main() {
24
+ const defaultValue = "my-nube-app";
25
+ const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent);
26
+ const cancel = (message = "Operation cancelled") => prompts.cancel(message);
27
+ const projectName = await prompts.text({
28
+ message: "What is the project's name?",
29
+ defaultValue,
30
+ placeholder: defaultValue
31
+ });
32
+ if (prompts.isCancel(projectName)) return cancel();
33
+ const templateName = await prompts.select({
34
+ message: "Select a template:",
35
+ options: [
36
+ { label: "Minimal", value: "minimal" },
37
+ { label: "Minimal with UI", value: "minimal-ui" },
38
+ { label: "Minimal with UI in JSX", value: "minimal-ui-jsx" }
39
+ ]
40
+ });
41
+ if (prompts.isCancel(templateName)) return cancel();
42
+ const dest = path.resolve(process.cwd(), toSlug(projectName));
43
+ const src = path.join(__dirname, `../templates/${templateName}`);
44
+ if (fs.existsSync(dest) && !isEmpty(dest)) {
45
+ cancel(`Template directory "${projectName}" is not empty.`);
46
+ return;
47
+ }
48
+ await fs.copy(src, dest);
49
+ const pkgManager = pkgInfo ? pkgInfo.name : "npm";
50
+ let doneMessage = "";
51
+ doneMessage += "Done. Now run:\n";
52
+ doneMessage += `
53
+ cd ${projectName}`;
54
+ switch (pkgManager) {
55
+ case "yarn":
56
+ doneMessage += "\n yarn";
57
+ doneMessage += "\n yarn build";
58
+ break;
59
+ default:
60
+ doneMessage += `
61
+ ${pkgManager} install`;
62
+ doneMessage += `
63
+ ${pkgManager} run build`;
64
+ break;
65
+ }
66
+ prompts.outro(doneMessage);
67
+ }
68
+ main();
package/package.json CHANGED
@@ -2,26 +2,34 @@
2
2
  "name": "create-nube-app",
3
3
  "description": "Create Nube App",
4
4
  "author": "Tiendanube / Nuvemshop",
5
- "license": "MIT",
6
- "version": "0.0.2",
5
+ "license": "MIT",
6
+ "version": "0.0.4",
7
7
  "bin": {
8
- "create-nube-app": "index.js"
8
+ "create-nube-app": "dist/index.js"
9
9
  },
10
10
  "scripts": {
11
11
  "build": "tsup",
12
12
  "check": "biome check src/*",
13
- "check:fix": "biome check --write src/*"
13
+ "check:fix": "biome check --write src/*"
14
14
  },
15
15
  "type": "module",
16
- "devDependencies": {
16
+ "dependencies": {
17
17
  "@clack/prompts": "^0.10.0",
18
+ "fs-extra": "^11.1.1"
19
+ },
20
+ "devDependencies": {
21
+ "@biomejs/biome": "1.8.3",
18
22
  "@types/fs-extra": "^11.0.4",
19
23
  "@types/node": "^22.13.11",
20
24
  "@types/prompts": "^2.4.9",
21
- "fs-extra": "^11.1.1",
22
- "prompts": "^2.4.2",
23
25
  "tsup": "^8.4.0",
24
- "typescript": "^5.6.2",
25
- "@biomejs/biome": "1.8.3"
26
- }
26
+ "typescript": "^5.6.2"
27
+ },
28
+ "files": [
29
+ "./dist",
30
+ "README.md",
31
+ "CHANGELOG.md",
32
+ "LICENSE",
33
+ "./templates"
34
+ ]
27
35
  }
package/biome.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
3
- "organizeImports": {
4
- "enabled": true
5
- },
6
- "linter": {
7
- "enabled": true,
8
- "rules": {
9
- "recommended": true
10
- }
11
- }
12
- }
package/index.js DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import './dist/index.js';
package/src/index.ts DELETED
@@ -1,81 +0,0 @@
1
- import path from "node:path";
2
- import { fileURLToPath } from "node:url";
3
- import * as prompts from "@clack/prompts";
4
- import fs from "fs-extra";
5
-
6
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
-
8
- function toSlug(text: string): string {
9
- return text.toLowerCase().replace(/\s+/g, "-");
10
- }
11
-
12
- interface PkgInfo {
13
- name: string;
14
- version: string;
15
- }
16
-
17
- function pkgFromUserAgent(userAgent: string | undefined): PkgInfo | undefined {
18
- if (!userAgent) return undefined;
19
- const pkgSpec = userAgent.split(" ")[0];
20
- const pkgSpecArr = pkgSpec.split("/");
21
- return {
22
- name: pkgSpecArr[0],
23
- version: pkgSpecArr[1],
24
- };
25
- }
26
-
27
- function isEmpty(path: string) {
28
- const files = fs.readdirSync(path);
29
- return files.length === 0 || (files.length === 1 && files[0] === ".git");
30
- }
31
-
32
- async function main(): Promise<void> {
33
- const defaultValue = "my-nube-app";
34
- const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent);
35
- const cancel = (message = "Operation cancelled") => prompts.cancel(message);
36
-
37
- const projectName = await prompts.text({
38
- message: "What is the project's name?",
39
- defaultValue,
40
- placeholder: defaultValue,
41
- });
42
- if (prompts.isCancel(projectName)) return cancel();
43
-
44
- const templateName = await prompts.select({
45
- message: "Select a template:",
46
- options: [
47
- { label: "minimal", value: "minimal" },
48
- { label: "minimal-ui", value: "minimal-ui" },
49
- { label: "minimal-ui-jsx", value: "minimal-ui-jsx" },
50
- ],
51
- });
52
- if (prompts.isCancel(templateName)) return cancel();
53
-
54
- const dest = path.resolve(process.cwd(), toSlug(projectName as string));
55
- const src = path.join(__dirname, `../templates/${templateName as string}`);
56
-
57
- if (fs.existsSync(dest) && !isEmpty(dest)) {
58
- cancel(`Template directory "${projectName}" is not empty.`);
59
- return;
60
- }
61
-
62
- await fs.copy(src, dest);
63
-
64
- const pkgManager = pkgInfo ? pkgInfo.name : "npm";
65
- let doneMessage = "";
66
- doneMessage += "Done. Now run:\n";
67
- doneMessage += `\n cd ${projectName as string}`;
68
- switch (pkgManager) {
69
- case "yarn":
70
- doneMessage += "\n yarn";
71
- doneMessage += "\n yarn build";
72
- break;
73
- default:
74
- doneMessage += `\n ${pkgManager} install`;
75
- doneMessage += `\n ${pkgManager} run build`;
76
- break;
77
- }
78
- prompts.outro(doneMessage);
79
- }
80
-
81
- main();
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "ESNext",
5
- "moduleResolution": "node",
6
- "esModuleInterop": true,
7
- "forceConsistentCasingInFileNames": true,
8
- "strict": true,
9
- "skipLibCheck": true,
10
- "types": [
11
- "node"
12
- ]
13
- }
14
- }
package/tsup.config.js DELETED
@@ -1,13 +0,0 @@
1
- // tsup.config.js
2
- import { defineConfig } from 'tsup';
3
-
4
- export default defineConfig({
5
- entry: ['src/index.ts'], // ponto de entrada do seu projeto
6
- format: ['esm'], // formatos de saída
7
- bundle: false, // não agrupa os módulos em um único arquivo
8
- minify: false, // desabilita a minificação
9
- sourcemap: false, // gera sourcemaps para facilitar o debug
10
- clean: true, // limpa a pasta de saída antes de cada build
11
- target: 'node16', // define o alvo (ajuste conforme sua versão do Node)
12
- dts: false, // gera arquivos de definição TypeScript (.d.ts)
13
- });