@orxataguy/tyr 1.0.23 → 1.0.25

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/bin/tyr.js CHANGED
@@ -8,7 +8,6 @@ const __filename = fileURLToPath(import.meta.url);
8
8
  const __dirname = dirname(__filename);
9
9
  const packageRoot = resolve(__dirname, '..');
10
10
 
11
- // Locate tsx's CLI entry directly from its package.json — no shell, no .cmd wrappers
12
11
  const tsxPkg = JSON.parse(readFileSync(join(packageRoot, 'node_modules', 'tsx', 'package.json'), 'utf-8'));
13
12
  const tsxBinField = tsxPkg.bin;
14
13
  const tsxBinRelative = typeof tsxBinField === 'string' ? tsxBinField : (tsxBinField.tsx ?? tsxBinField['tsx']);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orxataguy/tyr",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "tyr": "./bin/tyr.js"
@@ -22,10 +22,6 @@ interface TyrConfig {
22
22
  export interface TyrContext {
23
23
  frameworkRoot: string;
24
24
  userRoot: string;
25
- logger: any;
26
- shell: any;
27
- fs: any;
28
- docker?: any;
29
25
  run: (commandName: string, args?: string[]) => Promise<void>;
30
26
  task: <T>(description: string, action: () => Promise<T> | T, next?: boolean, onFail?: () => void) => Promise<T | undefined>;
31
27
  fail: (msg: string, suggestion?: string) => never;
@@ -54,12 +50,10 @@ export class Kernel {
54
50
  public async boot(args: string[]): Promise<void> {
55
51
  const isDebug = args.includes('--debug');
56
52
 
57
- // Load all env vars from ~/.tyr/.env once, before anything else
58
53
  (dotenv as any).config({ path: path.join(this.userRoot, '.env'), quiet: true });
59
54
 
60
55
  await this.container.init(isDebug);
61
56
 
62
- // All commands live in ~/.tyr/map.yml — the framework ships no runtime commands
63
57
  this.config = { commands: {}, aliases: {} };
64
58
 
65
59
  const userConfigPath = path.join(this.userRoot, 'map.yml');
@@ -67,7 +61,6 @@ export class Kernel {
67
61
  try {
68
62
  const raw = yaml.load(fs.readFileSync(userConfigPath, 'utf8')) as TyrConfig;
69
63
  for (const [name, cmdPath] of Object.entries(raw.commands ?? {})) {
70
- // Absolute paths used as-is; relative paths resolved from userRoot
71
64
  this.config.commands[name] = path.isAbsolute(cmdPath)
72
65
  ? cmdPath
73
66
  : path.resolve(this.userRoot, cmdPath);
@@ -91,7 +84,6 @@ export class Kernel {
91
84
  return;
92
85
  }
93
86
 
94
- // --version / -v
95
87
  if (commandName === '--version' || commandName === '-v') {
96
88
  const pkgPath = path.resolve(this.frameworkRoot, 'package.json');
97
89
  const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
@@ -99,7 +91,6 @@ export class Kernel {
99
91
  return;
100
92
  }
101
93
 
102
- // --update: pull latest changes from the linked ~/.tyr git repo
103
94
  if (commandName === '--update') {
104
95
  const shell = this.container.get().shell;
105
96
  const gitDir = path.join(this.userRoot, '.git');
@@ -115,7 +106,6 @@ export class Kernel {
115
106
  return;
116
107
  }
117
108
 
118
- // --upgrade: update the Tyr npm package itself
119
109
  if (commandName === '--upgrade') {
120
110
  const pkgPath = path.resolve(this.frameworkRoot, 'package.json');
121
111
  const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
@@ -126,7 +116,6 @@ export class Kernel {
126
116
  return;
127
117
  }
128
118
 
129
- // --help / -h: lists all available commands with their documentation
130
119
  if (commandName === '--help' || commandName === '-h') {
131
120
  const helpContext = {
132
121
  ...this.container.get(),
@@ -168,7 +157,6 @@ export class Kernel {
168
157
  fail: (msg: string, suggestion?: string) => { throw new TyrError(msg, null, suggestion, commandName); }
169
158
  };
170
159
 
171
- // --config (needs context for fs/logger)
172
160
  if (commandName === '--config') {
173
161
  await config(context)(args.slice(1));
174
162
  return;
@@ -202,12 +190,10 @@ export class Kernel {
202
190
  }
203
191
 
204
192
  try {
205
- // Absolute paths (user commands) are used directly; relative paths resolve from frameworkRoot
206
193
  const absolutePath = path.isAbsolute(scriptPath)
207
194
  ? scriptPath
208
195
  : path.resolve(this.frameworkRoot, scriptPath);
209
196
 
210
- // Convert to file:// URL — required by ESM on Windows for absolute paths
211
197
  const moduleUrl = pathToFileURL(absolutePath).href;
212
198
  const module = await import(moduleUrl);
213
199
 
@@ -75,7 +75,7 @@ const TSCONFIG_TEMPLATE = `{
75
75
  "compilerOptions": {
76
76
  "target": "ESNext",
77
77
  "module": "ESNext",
78
- "moduleResolution": "node",
78
+ "moduleResolution": "bundler",
79
79
  "esModuleInterop": true,
80
80
  "strict": true,
81
81
  "allowSyntheticDefaultImports": true,
@@ -86,8 +86,7 @@ const TSCONFIG_TEMPLATE = `{
86
86
  }
87
87
  `;
88
88
 
89
- const ENV_TEMPLATE = `# ~/.tyr/.env
90
- # Environment variables for Tyr. This file must never be committed to git.
89
+ const ENV_TEMPLATE = `# Environment variables for Tyr. This file must never be committed to git.
91
90
  #
92
91
  # SQL Server database
93
92
  MSSQL_USER=
@@ -99,8 +98,7 @@ MONGO_URI=
99
98
  MONGO_DATABASE=
100
99
  `;
101
100
 
102
- const SH_ALIASES_TEMPLATE = `# ~/.tyr/aliases
103
- # Add your custom aliases here.
101
+ const SH_ALIASES_TEMPLATE = `# Add your custom aliases here.
104
102
  # This file is loaded automatically by your shell.
105
103
  #
106
104
  # Examples:
@@ -108,30 +106,34 @@ const SH_ALIASES_TEMPLATE = `# ~/.tyr/aliases
108
106
  # alias tyr-deploy='tyr deploy'
109
107
  `;
110
108
 
111
- const SH_PLUGINS_TEMPLATE = `# ~/.tyr/plugins
112
- # Add your shell plugins here.
109
+ const SH_PLUGINS_TEMPLATE = `# Add your shell plugins here.
113
110
  # Compatible with zsh, bash and other POSIX shells.
114
111
  #
115
112
  # Examples (zsh):
116
113
  # source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
117
114
  `;
118
115
 
119
- const PS_ALIASES_TEMPLATE = `# ~/.tyr/aliases.ps1
120
- # Add your custom aliases for PowerShell here.
116
+ const PS_ALIASES_TEMPLATE = `# Add your custom aliases for PowerShell here.
121
117
  #
122
118
  # Examples:
123
119
  # Set-Alias gs git-status
124
120
  # function tyr-deploy { tyr deploy @args }
125
121
  `;
126
122
 
127
- const PS_PLUGINS_TEMPLATE = `# ~/.tyr/plugins.ps1
128
- # Add your PowerShell modules and plugins here.
123
+ const PS_PLUGINS_TEMPLATE = `# Add your PowerShell modules and plugins here.
129
124
  #
130
125
  # Examples:
131
126
  # Import-Module posh-git
132
127
  # Import-Module PSReadLine
133
128
  `;
134
129
 
130
+ const GIT_IGNORE = `# ENVIRONMENT
131
+ .env
132
+
133
+ # NODE
134
+ node_modules
135
+ `;
136
+
135
137
  function makeTimestamp(): string {
136
138
  const now = new Date();
137
139
  const pad = (n: number) => String(n).padStart(2, '0');
@@ -239,11 +241,17 @@ export default function config({ logger, fs: tyrFs, frameworkRoot, shell }: TyrC
239
241
  await tyrFs.write(mapPath, 'commands: {}\n');
240
242
  logger.success(`File created: ${mapPath}`);
241
243
 
242
- const envPath = path.join(userRoot, '.env');
244
+ const envPath = path.join(userRoot, '.env.example');
243
245
  if (!tyrFs.exists(envPath)) {
244
246
  await tyrFs.write(envPath, ENV_TEMPLATE);
245
247
  logger.success(`File created: ${envPath}`);
246
248
  }
249
+
250
+ const gitignorePath = path.join(userRoot, '.gitignore');
251
+ if (!tyrFs.exists(gitignorePath)) {
252
+ await tyrFs.write(gitignorePath, GIT_IGNORE);
253
+ logger.success(`File created: ${gitignorePath}`);
254
+ }
247
255
 
248
256
  const packageJsonPath = path.join(userRoot, 'package.json');
249
257
  if (!tyrFs.exists(packageJsonPath)) {
@@ -47,7 +47,6 @@ export default function gen({ logger, fs, userRoot }: TyrContext) {
47
47
  const templateFilled = template.replaceAll('%s', commandName);
48
48
  await fs.write(filePath, templateFilled.trim());
49
49
 
50
- // Register in ~/.tyr/map.yml
51
50
  const mapPath = path.join(userRoot, 'map.yml');
52
51
  try {
53
52
  const currentConfigRaw = await fs.read(mapPath);
@@ -59,7 +58,6 @@ export default function gen({ logger, fs, userRoot }: TyrContext) {
59
58
  logger.warn(`Command '${commandName}' already existed. Updating path...`);
60
59
  }
61
60
 
62
- // Store path relative to userRoot so it remains portable
63
61
  config.commands[commandName] = `./commands/${fileName}.tyr.ts`;
64
62
 
65
63
  const newYaml = yaml.dump(config, { indent: 2, lineWidth: -1 });
@@ -8,10 +8,6 @@ interface CommandDoc {
8
8
  usage: string;
9
9
  }
10
10
 
11
- /**
12
- * Extracts the first JSDoc block from a .tyr.ts file and parses it
13
- * into a description and usage examples.
14
- */
15
11
  function parseCommandDoc(filePath: string): CommandDoc {
16
12
  const fileName = path.basename(filePath, '.tyr.ts');
17
13
  const content = fs.readFileSync(filePath, 'utf-8');
@@ -21,12 +17,10 @@ function parseCommandDoc(filePath: string): CommandDoc {
21
17
  return { name: fileName, description: '', usage: '' };
22
18
  }
23
19
 
24
- // Clean each line: remove leading * and spaces
25
20
  const lines = match[1]
26
21
  .split('\n')
27
22
  .map(line => line.replace(/^\s*\*\s?/, '').trimEnd());
28
23
 
29
- // Split into description and "Usage:" block
30
24
  const usoIndex = lines.findIndex(l => /^uso:/i.test(l.trim()));
31
25
 
32
26
  let description = '';
@@ -74,7 +68,6 @@ export default function help({ userRoot }: TyrContext) {
74
68
  console.log(separator);
75
69
  console.log('');
76
70
 
77
- // Framework flags and built-in commands
78
71
  const builtins = [
79
72
  { name: '--help', description: 'Shows this command listing.', usage: 'tyr --help' },
80
73
  { name: '--version', description: 'Shows the installed version of tyr.', usage: 'tyr --version' },