@azure-net/cli 1.2.3 → 1.2.6

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.
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="Go" enabled="true" />
4
+ <component name="NewModuleRootManager">
5
+ <content url="file://$MODULE_DIR$" />
6
+ <orderEntry type="inheritedJdk" />
7
+ <orderEntry type="sourceFolder" forTests="false" />
8
+ </component>
9
+ </module>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/azure-net-ecosystem-cli.iml" filepath="$PROJECT_DIR$/.idea/azure-net-ecosystem-cli.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/bin/azure-net.js CHANGED
@@ -3,6 +3,7 @@
3
3
  import { Command } from 'commander';
4
4
  import generateRepository from '../src/commands/generateCrudRepo.js';
5
5
  import generateCrud from '../src/commands/generateCrud.js';
6
+ import initLint from '../src/commands/initLint.js';
6
7
 
7
8
  const program = new Command();
8
9
 
@@ -20,4 +21,9 @@ program
20
21
  .description('Generate CRUD Domain/Repo/Service')
21
22
  .action(generateCrud);
22
23
 
24
+ program
25
+ .command('init:lint')
26
+ .description('Setup linting and commit tools')
27
+ .action(initLint)
28
+
23
29
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-net/cli",
3
- "version": "1.2.3",
3
+ "version": "1.2.6",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "azure-net": "bin/azure-net.js"
@@ -0,0 +1,138 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { execSync } from 'child_process';
4
+ import prompts from 'prompts';
5
+
6
+ const dependencies = [
7
+ '@commitlint/cli',
8
+ 'semantic-release',
9
+ '@semantic-release/git',
10
+ 'git-cz',
11
+ 'husky',
12
+ 'commitizen',
13
+ 'env-cmd'
14
+ ];
15
+
16
+ const scriptsToAdd = {
17
+ precommit: 'pnpm lint && pnpm check',
18
+ 'semantic-release': 'env-cmd semantic-release',
19
+ commit: 'pnpm format && git add . && git-cz && git push',
20
+ release: 'pnpm commit && pnpm semantic-release'
21
+ };
22
+
23
+ const commitlintConfig = `export default {
24
+ rules: {
25
+ 'body-leading-blank': [2, 'always'],
26
+ 'footer-leading-blank': [2, 'always'],
27
+ 'header-max-length': [2, 'always', 72],
28
+ 'subject-empty': [2, 'never'],
29
+ 'subject-full-stop': [2, 'never', '.'],
30
+ 'type-case': [2, 'always', 'lower-case'],
31
+ 'type-empty': [2, 'never'],
32
+ 'type-enum': [2, 'always', ['feat', 'fix', 'refactor', 'perf', 'chore', 'docs', 'style', 'test', 'ci']]
33
+ }
34
+ };
35
+ `;
36
+
37
+ const releaseConfig = `export default {
38
+ branches: ['main', 'dev'],
39
+ dryRun: false,
40
+ ci: false,
41
+ plugins: [
42
+ [
43
+ '@semantic-release/commit-analyzer',
44
+ {
45
+ releaseRules: [
46
+ { type: 'release', release: 'major' },
47
+ { type: 'feature', release: 'minor' },
48
+ { type: 'perf', release: false },
49
+ { type: 'refactor', release: false },
50
+ { type: 'fix', release: 'patch' },
51
+ { type: 'chore', release: false },
52
+ { type: 'ci', release: false },
53
+ { type: 'docs', scope: 'README', release: false },
54
+ { type: 'test', release: false },
55
+ { type: 'style', release: false }
56
+ ]
57
+ }
58
+ ],
59
+ '@semantic-release/release-notes-generator'
60
+ ]
61
+ };
62
+ `;
63
+
64
+ const prettierConfig = `{
65
+ "useTabs": true,
66
+ "singleQuote": true,
67
+ "trailingComma": "none",
68
+ "tabWidth": 2,
69
+ "semi": true,
70
+ "printWidth": 150,
71
+ "plugins": ["prettier-plugin-svelte"],
72
+ "overrides": [
73
+ {
74
+ "files": "*.svelte",
75
+ "options": {
76
+ "parser": "svelte"
77
+ }
78
+ }
79
+ ]
80
+ }
81
+ `;
82
+
83
+ export default async function initLint() {
84
+ const cwd = process.cwd();
85
+ const pkgPath = path.join(cwd, 'package.json');
86
+
87
+ if (!fs.existsSync(pkgPath)) {
88
+ console.error('❌ package.json not found in this directory');
89
+ process.exit(1);
90
+ }
91
+
92
+ const { manager } = await prompts({
93
+ type: 'select',
94
+ name: 'manager',
95
+ message: 'Choose your package manager:',
96
+ choices: [
97
+ { title: 'pnpm', value: 'pnpm' },
98
+ { title: 'npm', value: 'npm' },
99
+ { title: 'yarn', value: 'yarn' }
100
+ ],
101
+ initial: 0
102
+ });
103
+
104
+ const installCommand =
105
+ manager === 'pnpm'
106
+ ? `pnpm add -D ${dependencies.join(' ')}`
107
+ : manager === 'npm'
108
+ ? `npm install -D ${dependencies.join(' ')}`
109
+ : `yarn add -D ${dependencies.join(' ')}`;
110
+
111
+ console.log(`📦 Installing packages with ${manager}...`);
112
+ execSync(installCommand, { stdio: 'inherit' });
113
+
114
+ console.log('📁 Updating package.json...');
115
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
116
+
117
+ pkg.scripts = {
118
+ ...pkg.scripts,
119
+ ...scriptsToAdd
120
+ };
121
+
122
+ pkg.config = pkg.config || {};
123
+ pkg.config.commitizen = {
124
+ path: 'git-cz'
125
+ };
126
+
127
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
128
+
129
+ // Write config files
130
+ fs.writeFileSync(path.join(cwd, 'commitlint.config.ts'), commitlintConfig);
131
+ fs.writeFileSync(path.join(cwd, 'release.config.ts'), releaseConfig);
132
+ fs.writeFileSync(path.join(cwd, '.prettierrc'), prettierConfig);
133
+
134
+ console.log('🔧 Initializing Husky...');
135
+ execSync(`${manager === 'npm' ? 'npx' : manager} husky`, { stdio: 'inherit' });
136
+
137
+ console.log('✅ Linting and release setup completed!');
138
+ }