@futurebrand/dev-tools 2.2.0 → 2.4.1

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 (66) hide show
  1. package/dist/bin.js +11 -0
  2. package/dist/commands/ai/add.d.ts +3 -0
  3. package/dist/commands/ai/add.js +46 -0
  4. package/dist/commands/ai/generate.d.ts +3 -0
  5. package/dist/commands/ai/generate.js +75 -0
  6. package/dist/commands/ai/index.d.ts +3 -0
  7. package/dist/commands/ai/index.js +43 -0
  8. package/dist/commands/ai/modules/figma/api.d.ts +8 -0
  9. package/dist/commands/ai/modules/figma/api.js +22 -0
  10. package/dist/commands/ai/modules/figma/index.d.ts +10 -0
  11. package/dist/commands/ai/modules/figma/index.js +104 -0
  12. package/dist/commands/ai/modules/figma/types.d.ts +40 -0
  13. package/dist/commands/ai/modules/generator/index.d.ts +17 -0
  14. package/dist/commands/ai/modules/generator/index.js +184 -0
  15. package/dist/commands/ai/modules/project-adder/index.d.ts +10 -0
  16. package/dist/commands/ai/modules/project-adder/index.js +78 -0
  17. package/dist/commands/ai/modules/state/index.d.ts +23 -0
  18. package/dist/commands/ai/modules/state/index.js +133 -0
  19. package/dist/commands/ai/modules/state/types.d.ts +29 -0
  20. package/dist/commands/ai/modules/state/types.js +2 -0
  21. package/dist/commands/ai/remove.d.ts +3 -0
  22. package/dist/commands/ai/remove.js +42 -0
  23. package/dist/commands/index.d.ts +7 -0
  24. package/dist/commands/index.js +21 -0
  25. package/dist/{bin/commands → commands}/project-setup/configs.d.ts +1 -1
  26. package/dist/{bin/commands → commands}/project-setup/configs.js +1 -0
  27. package/dist/commands/project-setup/index.js +22 -0
  28. package/dist/commands/project-setup/utils/files.d.ts +2 -0
  29. package/dist/commands/project-setup/utils/files.js +21 -0
  30. package/dist/commands/project-setup/utils/lint.d.ts +3 -0
  31. package/dist/commands/project-setup/utils/lint.js +22 -0
  32. package/dist/commands/project-setup/utils/packages.d.ts +5 -0
  33. package/dist/{bin/commands/project-setup/modules → commands/project-setup/utils}/packages.js +17 -8
  34. package/dist/modules/parallel/index.d.ts +16 -0
  35. package/dist/modules/parallel/index.js +50 -0
  36. package/dist/plugins/prettier/prettier.d.mts +7 -5
  37. package/dist/types/project.d.ts +20 -0
  38. package/dist/types/project.js +2 -0
  39. package/dist/utils/files.d.ts +10 -0
  40. package/dist/utils/files.js +84 -0
  41. package/dist/utils/package-manager.d.ts +4 -0
  42. package/dist/utils/package-manager.js +40 -0
  43. package/dist/utils/project-type.d.ts +2 -0
  44. package/dist/utils/project-type.js +66 -0
  45. package/dist/utils/project.d.ts +2 -0
  46. package/dist/utils/project.js +43 -0
  47. package/dist/utils/sleep.d.ts +1 -0
  48. package/dist/utils/sleep.js +6 -0
  49. package/package.json +25 -22
  50. package/dist/bin/commands/index.d.ts +0 -2
  51. package/dist/bin/commands/index.js +0 -7
  52. package/dist/bin/commands/project-setup/index.js +0 -22
  53. package/dist/bin/commands/project-setup/modules/files.d.ts +0 -2
  54. package/dist/bin/commands/project-setup/modules/files.js +0 -29
  55. package/dist/bin/commands/project-setup/modules/packages.d.ts +0 -3
  56. package/dist/bin/index.js +0 -20
  57. package/dist/bin/modules/files.d.ts +0 -6
  58. package/dist/bin/modules/files.js +0 -68
  59. package/dist/bin/modules/package-manager.d.ts +0 -1
  60. package/dist/bin/modules/package-manager.js +0 -15
  61. package/dist/bin/modules/project-type.d.ts +0 -2
  62. package/dist/bin/modules/project-type.js +0 -36
  63. package/dist/bin/types.d.ts +0 -8
  64. /package/dist/{bin/index.d.ts → bin.d.ts} +0 -0
  65. /package/dist/{bin → commands/ai/modules/figma}/types.js +0 -0
  66. /package/dist/{bin/commands → commands}/project-setup/index.d.ts +0 -0
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPackageManager = getPackageManager;
4
+ exports.loadPackageJson = loadPackageJson;
5
+ exports.writePackageJson = writePackageJson;
6
+ const path = require("path");
7
+ const files_1 = require("./files");
8
+ async function getPackageManager(projectPath) {
9
+ const pnpmFilePath = path.join(projectPath, 'pnpm-lock.yaml');
10
+ const isPNPM = await (0, files_1.verifyPath)(pnpmFilePath);
11
+ if (isPNPM) {
12
+ return 'pnpm';
13
+ }
14
+ const yarnFilePath = path.join(projectPath, 'yarn.lock');
15
+ const isYarn = await (0, files_1.verifyPath)(yarnFilePath);
16
+ if (isYarn) {
17
+ return 'yarn';
18
+ }
19
+ return 'npm';
20
+ }
21
+ async function loadPackageJson(projectPath) {
22
+ const filePath = path.join(projectPath, 'package.json');
23
+ try {
24
+ const file = await (0, files_1.loadJSONFile)(filePath);
25
+ return file;
26
+ }
27
+ catch {
28
+ return null;
29
+ }
30
+ }
31
+ async function writePackageJson(projectPath, data) {
32
+ const filePath = path.join(projectPath, 'package.json');
33
+ try {
34
+ await (0, files_1.writeJSONFile)(filePath, data);
35
+ }
36
+ catch (error) {
37
+ console.error(`Failed to load package.json`);
38
+ throw error;
39
+ }
40
+ }
@@ -0,0 +1,2 @@
1
+ import type { ProjectType } from '../types/project';
2
+ export declare function getProjectType(folderPath: string): Promise<ProjectType>;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getProjectType = getProjectType;
4
+ const files_1 = require("../utils/files");
5
+ const package_manager_1 = require("../utils/package-manager");
6
+ const inquirer_1 = require("inquirer");
7
+ const PROJECT_TYPES = ['next.js', 'react', 'strapi', 'node'];
8
+ async function getProjectTypeFromPackage(folderPath) {
9
+ try {
10
+ const packageJson = await (0, package_manager_1.loadPackageJson)(folderPath);
11
+ if (!packageJson) {
12
+ return null;
13
+ }
14
+ const { dependencies, devDependencies, name } = packageJson;
15
+ if (name.startsWith('@futurebrand/')) {
16
+ return 'node';
17
+ }
18
+ if (dependencies) {
19
+ if (dependencies['next'] != null) {
20
+ return 'next.js';
21
+ }
22
+ if (dependencies['@strapi/strapi'] != null) {
23
+ return 'strapi';
24
+ }
25
+ if (dependencies['fastify'] != null || dependencies['tsx'] != null) {
26
+ return 'node';
27
+ }
28
+ if (dependencies['react'] != null) {
29
+ return 'react';
30
+ }
31
+ }
32
+ if (devDependencies) {
33
+ if (devDependencies['tsx'] != null) {
34
+ return 'node';
35
+ }
36
+ }
37
+ return null;
38
+ }
39
+ catch (error) {
40
+ console.error(error);
41
+ return null;
42
+ }
43
+ }
44
+ async function getProjectTypeFromUser(folderPath) {
45
+ const rootPath = (0, files_1.getRootPath)();
46
+ let folderWithoutRoot = folderPath.replace(rootPath, '');
47
+ if (!folderWithoutRoot.startsWith('/')) {
48
+ folderWithoutRoot = `/${folderWithoutRoot}`;
49
+ }
50
+ const { projectType } = await inquirer_1.default.prompt([
51
+ {
52
+ type: 'list',
53
+ name: 'projectType',
54
+ message: `Select the project type for ".${folderWithoutRoot}"`,
55
+ choices: PROJECT_TYPES,
56
+ },
57
+ ]);
58
+ return projectType;
59
+ }
60
+ async function getProjectType(folderPath) {
61
+ const packageType = await getProjectTypeFromPackage(folderPath);
62
+ if (packageType) {
63
+ return packageType;
64
+ }
65
+ return getProjectTypeFromUser(folderPath);
66
+ }
@@ -0,0 +1,2 @@
1
+ import type { IProject } from '../types/project';
2
+ export declare function getProjects(): Promise<IProject[]>;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getProjects = getProjects;
4
+ const path = require("path");
5
+ const files_1 = require("./files");
6
+ const package_manager_1 = require("./package-manager");
7
+ const project_type_1 = require("./project-type");
8
+ const PROJECTS_DIRS = ['', 'backend', 'frontend', 'server', 'scripts'];
9
+ async function verifyProjectPath(relativePath) {
10
+ const projectPath = (0, files_1.getRootPath)(relativePath);
11
+ const packageJson = await (0, package_manager_1.loadPackageJson)(projectPath);
12
+ if (!packageJson) {
13
+ return null;
14
+ }
15
+ const projectType = await (0, project_type_1.getProjectType)(projectPath);
16
+ if (projectType === 'next.js') {
17
+ const projectAppFolder = path.join(projectPath, 'app');
18
+ const isAppProject = await (0, files_1.verifyPath)(projectAppFolder);
19
+ return {
20
+ name: packageJson.name,
21
+ relativePath: `./${relativePath}`,
22
+ path: projectPath,
23
+ type: projectType,
24
+ appDir: isAppProject,
25
+ };
26
+ }
27
+ return {
28
+ name: packageJson.name,
29
+ relativePath: `./${relativePath}`,
30
+ path: projectPath,
31
+ type: projectType,
32
+ };
33
+ }
34
+ async function getProjects() {
35
+ const projects = [];
36
+ for (const relativePath of PROJECTS_DIRS) {
37
+ const project = await verifyProjectPath(relativePath);
38
+ if (project) {
39
+ projects.push(project);
40
+ }
41
+ }
42
+ return projects;
43
+ }
@@ -0,0 +1 @@
1
+ export declare function sleep(ms: number): Promise<unknown>;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sleep = sleep;
4
+ async function sleep(ms) {
5
+ return new Promise((resolve) => setTimeout(resolve, ms));
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@futurebrand/dev-tools",
3
- "version": "2.2.0",
3
+ "version": "2.4.1",
4
4
  "description": "FutureBrand Dev Tools",
5
5
  "scripts": {
6
6
  "build": "tsc && tsc-alias",
@@ -22,7 +22,7 @@
22
22
  "package.json"
23
23
  ],
24
24
  "bin": {
25
- "fb": "./dist/bin/index.js"
25
+ "fub": "./dist/bin.js"
26
26
  },
27
27
  "exports": {
28
28
  "./plugins": "./dist/plugins/index.mjs",
@@ -52,38 +52,41 @@
52
52
  }
53
53
  },
54
54
  "dependencies": {
55
- "@eslint/js": "^9.22.0",
56
- "@next/eslint-plugin-next": "^15.2.3",
57
- "commander": "^13.1.0",
58
- "eslint": "^9.22.0",
59
- "eslint-config-prettier": "^10.1.1",
60
- "eslint-plugin-prettier": "^5.2.3",
55
+ "@eslint/js": "^9.29.0",
56
+ "@next/eslint-plugin-next": "^15.3.4",
57
+ "cli-progress": "^3.12.0",
58
+ "commander": "^14.0.0",
59
+ "eslint": "^9.29.0",
60
+ "eslint-config-prettier": "^10.1.5",
61
+ "eslint-plugin-prettier": "^5.5.0",
61
62
  "eslint-plugin-simple-import-sort": "^12.1.1",
62
- "globals": "^16.0.0",
63
- "inquirer": "^12.5.0",
64
- "prettier": "^3.5.3",
65
- "prettier-plugin-tailwindcss": "^0.6.11",
66
- "typescript-eslint": "^8.26.1"
63
+ "globals": "^16.2.0",
64
+ "inquirer": "^12.6.3",
65
+ "prettier": "^3.6.0",
66
+ "prettier-plugin-tailwindcss": "^0.6.13",
67
+ "typescript-eslint": "^8.35.0"
67
68
  },
68
69
  "devDependencies": {
69
- "@types/node": "^22.13.10",
70
- "@typescript-eslint/utils": "^8.26.1",
70
+ "@types/cli-progress": "^3.11.6",
71
+ "@types/node": "^24.0.3",
72
+ "@typescript-eslint/utils": "^8.35.0",
71
73
  "jiti": "^2.4.2",
72
- "tsc-alias": "^1.8.11",
73
- "typescript": "^5.8.2"
74
+ "tsc-alias": "^1.8.16",
75
+ "typescript": "^5.8.3"
74
76
  },
75
77
  "peerDependencies": {
76
78
  "eslint": "^9.21.0",
77
79
  "prettier": "^3.5.2"
78
80
  },
79
81
  "overrides": {
80
- "eslint": "^9.22.0",
81
- "prettier": "^3.5.3"
82
+ "eslint": "^9.29.0",
83
+ "prettier": "^3.6.0"
82
84
  },
83
85
  "pnpm": {
84
86
  "overrides": {
85
- "eslint": "^9.22.0",
86
- "prettier": "^3.5.3"
87
+ "eslint": "^9.29.0",
88
+ "prettier": "^3.6.0"
87
89
  }
88
- }
90
+ },
91
+ "packageManager": "pnpm@10.12.3"
89
92
  }
@@ -1,2 +0,0 @@
1
- import type { Command } from 'commander';
2
- export declare function addCommands(program: Command): void;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addCommands = addCommands;
4
- const project_setup_1 = require("./project-setup");
5
- function addCommands(program) {
6
- program.addCommand(project_setup_1.default);
7
- }
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const commander_1 = require("commander");
4
- const files_1 = require("../../modules/files");
5
- const project_type_1 = require("../../modules/project-type");
6
- const configs_1 = require("./configs");
7
- const files_2 = require("./modules/files");
8
- const packages_1 = require("./modules/packages");
9
- const projectSetup = new commander_1.Command('setup')
10
- .description('Setup project with default configurations')
11
- .action(async () => {
12
- const projectType = await (0, project_type_1.getProjectType)();
13
- const eslintConfigName = configs_1.ESLINT_PLUGIN_NAMES[projectType];
14
- await (0, files_1.deleteUnusedFiles)();
15
- const eslintConfig = (0, files_2.getPluginConfig)(eslintConfigName);
16
- const prettierConfig = (0, files_2.getPluginConfig)(configs_1.PRETTIER_PLUGIN_NAME);
17
- await (0, files_1.writeFile)(configs_1.ESLINT_CONFIG_FILE, eslintConfig);
18
- await (0, files_1.writeFile)(configs_1.PRETTIER_CONFIG_FILE, prettierConfig);
19
- await (0, packages_1.removeUnusedPackages)();
20
- await (0, packages_1.installDependencies)();
21
- });
22
- exports.default = projectSetup;
@@ -1,2 +0,0 @@
1
- export declare function deleteUnusedFiles(): Promise<void>;
2
- export declare function getPluginConfig(pluginImportName: string): string;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deleteUnusedFiles = deleteUnusedFiles;
4
- exports.getPluginConfig = getPluginConfig;
5
- const fs = require("node:fs/promises");
6
- const path = require("node:path");
7
- const files_1 = require("../../../modules/files");
8
- const configs_1 = require("../configs");
9
- async function deleteUnusedFiles() {
10
- const root = process.cwd();
11
- for (const file of configs_1.UNUSED_FILES) {
12
- const filePath = path.join(root, file);
13
- try {
14
- if (await (0, files_1.verifyFileExist)(filePath)) {
15
- await fs.unlink(filePath);
16
- }
17
- }
18
- catch (error) {
19
- console.error(`Failed to delete ${filePath}`);
20
- throw error;
21
- }
22
- }
23
- }
24
- function getPluginConfig(pluginImportName) {
25
- return `import { ${pluginImportName} } from '@futurebrand/dev-tools/plugins'
26
-
27
- export default ${pluginImportName}
28
- `;
29
- }
@@ -1,3 +0,0 @@
1
- export declare function removeEslintDependencies(dependencies: Record<string, string>): void;
2
- export declare function removeUnusedPackages(): Promise<void>;
3
- export declare function installDependencies(): Promise<void>;
package/dist/bin/index.js DELETED
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const commander_1 = require("commander");
5
- const package_json_1 = require("../../package.json");
6
- const commands_1 = require("./commands");
7
- commander_1.program
8
- .version(package_json_1.version)
9
- .description(package_json_1.description)
10
- .option('-n, --name <type>', 'Add your name')
11
- .action((options) => {
12
- if (options.name) {
13
- console.warn(`Hello ${options.name}!`);
14
- }
15
- else {
16
- console.warn('Hello Futurebrand!');
17
- }
18
- });
19
- (0, commands_1.addCommands)(commander_1.program);
20
- commander_1.program.parse(process.argv);
@@ -1,6 +0,0 @@
1
- import type { PackageJson } from '../types';
2
- export declare function verifyFileExist(filePath: string): Promise<boolean>;
3
- export declare function deleteUnusedFiles(): Promise<void>;
4
- export declare function writeFile(fileName: string, config: string): Promise<void>;
5
- export declare function loadPackageJson(): Promise<PackageJson>;
6
- export declare function writePackageJson(data: PackageJson): Promise<void>;
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.verifyFileExist = verifyFileExist;
4
- exports.deleteUnusedFiles = deleteUnusedFiles;
5
- exports.writeFile = writeFile;
6
- exports.loadPackageJson = loadPackageJson;
7
- exports.writePackageJson = writePackageJson;
8
- const fs = require("node:fs/promises");
9
- const path = require("node:path");
10
- const configs_1 = require("../commands/project-setup/configs");
11
- async function verifyFileExist(filePath) {
12
- try {
13
- await fs.access(filePath);
14
- return true;
15
- }
16
- catch {
17
- return false;
18
- }
19
- }
20
- async function deleteUnusedFiles() {
21
- const root = process.cwd();
22
- for (const file of configs_1.UNUSED_FILES) {
23
- const filePath = path.join(root, file);
24
- try {
25
- if (await verifyFileExist(filePath)) {
26
- await fs.unlink(filePath);
27
- }
28
- }
29
- catch (error) {
30
- console.error(`Failed to delete ${filePath}`);
31
- throw error;
32
- }
33
- }
34
- }
35
- async function writeFile(fileName, config) {
36
- const root = process.cwd();
37
- const filePath = path.join(root, fileName);
38
- try {
39
- await fs.writeFile(filePath, config);
40
- }
41
- catch (error) {
42
- console.error(`Failed to write ${filePath}`);
43
- throw error;
44
- }
45
- }
46
- async function loadPackageJson() {
47
- const root = process.cwd();
48
- const filePath = path.join(root, 'package.json');
49
- try {
50
- const file = await fs.readFile(filePath, 'utf-8');
51
- return JSON.parse(file);
52
- }
53
- catch (error) {
54
- console.error(`Failed to load ${filePath}`);
55
- throw error;
56
- }
57
- }
58
- async function writePackageJson(data) {
59
- const root = process.cwd();
60
- const filePath = path.join(root, 'package.json');
61
- try {
62
- await fs.writeFile(filePath, JSON.stringify(data, null, 2));
63
- }
64
- catch (error) {
65
- console.error(`Failed to load ${filePath}`);
66
- throw error;
67
- }
68
- }
@@ -1 +0,0 @@
1
- export declare function getPackageManager(): Promise<"pnpm" | "yarn" | "npm">;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPackageManager = getPackageManager;
4
- const files_1 = require("./files");
5
- async function getPackageManager() {
6
- const isPNPM = await (0, files_1.verifyFileExist)('pnpm-lock.yaml');
7
- if (isPNPM) {
8
- return 'pnpm';
9
- }
10
- const isYarn = await (0, files_1.verifyFileExist)('yarn.lock');
11
- if (isYarn) {
12
- return 'yarn';
13
- }
14
- return 'npm';
15
- }
@@ -1,2 +0,0 @@
1
- import type { ProjectType } from '../types';
2
- export declare function getProjectType(): Promise<ProjectType>;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getProjectType = getProjectType;
4
- const files_1 = require("../modules/files");
5
- const inquirer_1 = require("inquirer");
6
- const PROJECT_TYPES = ['next.js', 'react', 'node'];
7
- async function isNextProject() {
8
- if (await (0, files_1.verifyFileExist)('next.config.js')) {
9
- return true;
10
- }
11
- const packageJson = await (0, files_1.loadPackageJson)();
12
- return packageJson.dependencies['next'] != null;
13
- }
14
- async function isStrapiProject() {
15
- const packageJson = await (0, files_1.loadPackageJson)();
16
- return packageJson.dependencies['@strapi/strapi'] != null;
17
- }
18
- async function getProjectType() {
19
- const isNext = await isNextProject();
20
- if (isNext) {
21
- return 'next.js';
22
- }
23
- const isStrapi = await isStrapiProject();
24
- if (isStrapi) {
25
- return 'node';
26
- }
27
- const { projectType } = await inquirer_1.default.prompt([
28
- {
29
- type: 'list',
30
- name: 'projectType',
31
- message: 'Select the project type',
32
- choices: PROJECT_TYPES,
33
- },
34
- ]);
35
- return projectType;
36
- }
@@ -1,8 +0,0 @@
1
- export type ProjectType = 'next.js' | 'react' | 'node';
2
- export interface PackageJson {
3
- name: string;
4
- version: string;
5
- scripts: Record<string, string>;
6
- devDependencies: Record<string, string>;
7
- dependencies: Record<string, string>;
8
- }
File without changes