@a5gard/asgard 0.0.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.
- package/.env +2 -0
- package/.gitignore copy +6 -0
- package/.vscode/ntrsync/.vscode/ocrmnavigator/id.txt +1 -0
- package/.vscode/ntrsync/.vscode/ocrmnavigator.code-snippets +3664 -0
- package/.vscode/ntrsync/00002_CRM URGENT_todo.md +79 -0
- package/.vscode/ntrsync/10005_notes repo url.md +3 -0
- package/.vscode/ntrsync/10012_vscode_color_settings.md +133 -0
- package/.vscode/ntrsync/10013_Googles Snapchat Upload Hack note.md +11 -0
- package/.vscode/ntrsync/10014_APP IDEA - Lawyer CRM.md +229 -0
- package/.vscode/ntrsync/10015_APP IDEA - Onlyfans.md +293 -0
- package/.vscode/ntrsync/10016_notes repo url.md +3 -0
- package/.vscode/ntrsync/10504_adhd symptom.md +3 -0
- package/.vscode/ntrsync/10505_APP IDEA - GMAIL.md +39 -0
- package/.vscode/ntrsync/10506_container home - build mats.md +18 -0
- package/.vscode/ntrsync/10507_cleint facing site meta and loader function.md +25 -0
- package/.vscode/ntrsync/10508_Sabaak VSCode 1-8 players - private teams, solo q, duos q.md +11 -0
- package/.vscode/ntrsync/10509_schema dump.md +80 -0
- package/.vscode/ntrsync/10510_APPT BEACONHILL_reminder.md +7 -0
- package/.vscode/ntrsync/10512_clipboard very usefull should use asap within all apps.md +101 -0
- package/.vscode/ntrsync/10516_DevStack_todo.md +130 -0
- package/.vscode/ntrsync/10517_CRM_todo.md +95 -0
- package/.vscode/ntrsync/10518_Catalyst POS_todo.md +73 -0
- package/.vscode/ntrsync/10519_Catalyst Software_todo.md +497 -0
- package/.vscode/ntrsync/10523_new note.md +6 -0
- package/.vscode/ntrsync/10524_New Reminder_reminder.md +5 -0
- package/.vscode/ntrsync/10525_Mobile - Notes, To-Dos And Things_todo.md +4 -0
- package/.vscode/ntrsync/90002_COMPLETED_todo.md +97 -0
- package/.vscode/ntrsync/README.md +1 -0
- package/.vscode/ocrmnavigator/id.txt +1 -0
- package/.vscode/ocrmnavigator.code-snippets +349 -0
- package/.vscode/settings.json +1 -0
- package/CHANGELOG.md +6 -0
- package/LICENSE.md +21 -0
- package/README.md +1612 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +17 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +5 -0
- package/config.asgard +8 -0
- package/dist/commands/add-source.d.ts +9 -0
- package/dist/commands/add-source.d.ts.map +1 -0
- package/dist/commands/add-source.js +68 -0
- package/dist/commands/add-source.js.map +1 -0
- package/dist/commands/baldr.d.ts +5 -0
- package/dist/commands/baldr.d.ts.map +1 -0
- package/dist/commands/baldr.js +35 -0
- package/dist/commands/baldr.js.map +1 -0
- package/dist/commands/combine-timelines.d.ts +5 -0
- package/dist/commands/combine-timelines.d.ts.map +1 -0
- package/dist/commands/combine-timelines.js +53 -0
- package/dist/commands/combine-timelines.js.map +1 -0
- package/dist/commands/create-project.d.ts +10 -0
- package/dist/commands/create-project.d.ts.map +1 -0
- package/dist/commands/create-project.js +195 -0
- package/dist/commands/create-project.js.map +1 -0
- package/dist/commands/create-timeline.d.ts +8 -0
- package/dist/commands/create-timeline.d.ts.map +1 -0
- package/dist/commands/create-timeline.js +54 -0
- package/dist/commands/create-timeline.js.map +1 -0
- package/dist/commands/delete-project.d.ts +5 -0
- package/dist/commands/delete-project.d.ts.map +1 -0
- package/dist/commands/delete-project.js +47 -0
- package/dist/commands/delete-project.js.map +1 -0
- package/dist/commands/delete-source.d.ts +8 -0
- package/dist/commands/delete-source.d.ts.map +1 -0
- package/dist/commands/delete-source.js +57 -0
- package/dist/commands/delete-source.js.map +1 -0
- package/dist/commands/delete-timeline.d.ts +8 -0
- package/dist/commands/delete-timeline.d.ts.map +1 -0
- package/dist/commands/delete-timeline.js +54 -0
- package/dist/commands/delete-timeline.js.map +1 -0
- package/dist/commands/delete-version.d.ts +8 -0
- package/dist/commands/delete-version.d.ts.map +1 -0
- package/dist/commands/delete-version.js +65 -0
- package/dist/commands/delete-version.js.map +1 -0
- package/dist/commands/download-file.d.ts +17 -0
- package/dist/commands/download-file.d.ts.map +1 -0
- package/dist/commands/download-file.js +87 -0
- package/dist/commands/download-file.js.map +1 -0
- package/dist/commands/download-folder.d.ts +18 -0
- package/dist/commands/download-folder.d.ts.map +1 -0
- package/dist/commands/download-folder.js +111 -0
- package/dist/commands/download-folder.js.map +1 -0
- package/dist/commands/download-source.d.ts +12 -0
- package/dist/commands/download-source.d.ts.map +1 -0
- package/dist/commands/download-source.js +46 -0
- package/dist/commands/download-source.js.map +1 -0
- package/dist/commands/gh-setup.d.ts +7 -0
- package/dist/commands/gh-setup.d.ts.map +1 -0
- package/dist/commands/gh-setup.js +106 -0
- package/dist/commands/gh-setup.js.map +1 -0
- package/dist/commands/load-project.d.ts +5 -0
- package/dist/commands/load-project.d.ts.map +1 -0
- package/dist/commands/load-project.js +56 -0
- package/dist/commands/load-project.js.map +1 -0
- package/dist/commands/menu.d.ts +5 -0
- package/dist/commands/menu.d.ts.map +1 -0
- package/dist/commands/menu.js +41 -0
- package/dist/commands/menu.js.map +1 -0
- package/dist/commands/midgardr.d.ts +5 -0
- package/dist/commands/midgardr.d.ts.map +1 -0
- package/dist/commands/midgardr.js +24 -0
- package/dist/commands/midgardr.js.map +1 -0
- package/dist/commands/publish-project.d.ts +5 -0
- package/dist/commands/publish-project.d.ts.map +1 -0
- package/dist/commands/publish-project.js +102 -0
- package/dist/commands/publish-project.js.map +1 -0
- package/dist/commands/replace-timeline.d.ts +8 -0
- package/dist/commands/replace-timeline.d.ts.map +1 -0
- package/dist/commands/replace-timeline.js +63 -0
- package/dist/commands/replace-timeline.js.map +1 -0
- package/dist/commands/restore-version.d.ts +8 -0
- package/dist/commands/restore-version.d.ts.map +1 -0
- package/dist/commands/restore-version.js +67 -0
- package/dist/commands/restore-version.js.map +1 -0
- package/dist/commands/save-project.d.ts +8 -0
- package/dist/commands/save-project.d.ts.map +1 -0
- package/dist/commands/save-project.js +43 -0
- package/dist/commands/save-project.js.map +1 -0
- package/dist/commands/set-source.d.ts +9 -0
- package/dist/commands/set-source.d.ts.map +1 -0
- package/dist/commands/set-source.js +59 -0
- package/dist/commands/set-source.js.map +1 -0
- package/dist/commands/switch-timeline.d.ts +8 -0
- package/dist/commands/switch-timeline.d.ts.map +1 -0
- package/dist/commands/switch-timeline.js +61 -0
- package/dist/commands/switch-timeline.js.map +1 -0
- package/dist/commands/sync-source.d.ts +5 -0
- package/dist/commands/sync-source.d.ts.map +1 -0
- package/dist/commands/sync-source.js +29 -0
- package/dist/commands/sync-source.js.map +1 -0
- package/dist/commands/upload-project+++.d.ts +5 -0
- package/dist/commands/upload-project+++.d.ts.map +1 -0
- package/dist/commands/upload-project+++.js +32 -0
- package/dist/commands/upload-project+++.js.map +1 -0
- package/dist/commands/upload-project++.d.ts +5 -0
- package/dist/commands/upload-project++.d.ts.map +1 -0
- package/dist/commands/upload-project++.js +33 -0
- package/dist/commands/upload-project++.js.map +1 -0
- package/dist/commands/upload-project+.d.ts +5 -0
- package/dist/commands/upload-project+.d.ts.map +1 -0
- package/dist/commands/upload-project+.js +40 -0
- package/dist/commands/upload-project+.js.map +1 -0
- package/dist/commands/upload-project.d.ts +5 -0
- package/dist/commands/upload-project.d.ts.map +1 -0
- package/dist/commands/upload-project.js +29 -0
- package/dist/commands/upload-project.js.map +1 -0
- package/dist/commands/view-timeline.d.ts +5 -0
- package/dist/commands/view-timeline.d.ts.map +1 -0
- package/dist/commands/view-timeline.js +39 -0
- package/dist/commands/view-timeline.js.map +1 -0
- package/dist/commands/view-versions.d.ts +5 -0
- package/dist/commands/view-versions.d.ts.map +1 -0
- package/dist/commands/view-versions.js +45 -0
- package/dist/commands/view-versions.js.map +1 -0
- package/dist/git/helpers.d.ts +10 -0
- package/dist/git/helpers.d.ts.map +1 -0
- package/dist/git/helpers.js +300 -0
- package/dist/git/helpers.js.map +1 -0
- package/dist/git/sync-repo.d.ts +2 -0
- package/dist/git/sync-repo.d.ts.map +1 -0
- package/dist/git/sync-repo.js +17 -0
- package/dist/git/sync-repo.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/box.d.ts +11 -0
- package/dist/utils/box.d.ts.map +1 -0
- package/dist/utils/box.js +158 -0
- package/dist/utils/box.js.map +1 -0
- package/ideas.md +46 -0
- package/package.json +53 -0
- package/src/commands/add-source.js +72 -0
- package/src/commands/baldr.js +38 -0
- package/src/commands/combine-timelines.js +65 -0
- package/src/commands/create-project.js +216 -0
- package/src/commands/create-timeline.js +60 -0
- package/src/commands/delete-project.js +54 -0
- package/src/commands/delete-source.js +63 -0
- package/src/commands/delete-timeline.js +63 -0
- package/src/commands/delete-version.js +74 -0
- package/src/commands/download-file.js +101 -0
- package/src/commands/download-folder.js +123 -0
- package/src/commands/download-source.js +51 -0
- package/src/commands/gh-setup.js +77 -0
- package/src/commands/load-project.js +63 -0
- package/src/commands/menu.js +46 -0
- package/src/commands/midgardr.js +25 -0
- package/src/commands/publish-project.js +167 -0
- package/src/commands/replace-timeline.js +76 -0
- package/src/commands/restore-version.js +80 -0
- package/src/commands/save-project.js +48 -0
- package/src/commands/set-source.js +65 -0
- package/src/commands/switch-timeline.js +69 -0
- package/src/commands/sync-source.js +32 -0
- package/src/commands/upload-project+++.js +34 -0
- package/src/commands/upload-project++.js +35 -0
- package/src/commands/upload-project+.js +47 -0
- package/src/commands/upload-project.js +31 -0
- package/src/commands/view-timeline.js +43 -0
- package/src/commands/view-versions.js +50 -0
- package/src/git/helpers.js +333 -0
- package/src/git/sync-repo.js +16 -0
- package/src/index.js +2 -0
- package/src/utils/box.js +282 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import ora from 'ora';
|
|
6
|
+
import { getLicenseContent, ensureGitConfig } from '../git/helpers.js';
|
|
7
|
+
import { boxStart, boxDivider, boxEnd, boxLine } from '../utils/box.js';
|
|
8
|
+
|
|
9
|
+
export default class PublishProject extends Command {
|
|
10
|
+
static description = 'Create GitHub repository for existing project';
|
|
11
|
+
|
|
12
|
+
async run() {
|
|
13
|
+
boxStart('Publish Project');
|
|
14
|
+
|
|
15
|
+
await ensureGitConfig();
|
|
16
|
+
|
|
17
|
+
const cwd = process.cwd();
|
|
18
|
+
const configPath = path.join(cwd, 'config.asgard');
|
|
19
|
+
const spinner = ora('Preparing project...').start();
|
|
20
|
+
|
|
21
|
+
let config = { branch: 'main' };
|
|
22
|
+
if (fs.existsSync(configPath)) {
|
|
23
|
+
config = await fs.readJson(configPath);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const targetBranch = config.branch || 'main';
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
execSync('gh auth status', { stdio: 'ignore' });
|
|
30
|
+
} catch (e) {
|
|
31
|
+
spinner.stop();
|
|
32
|
+
boxLine('You are not logged into GitHub CLI.', 'warning');
|
|
33
|
+
boxLine('Please run: asgard gh-setup', 'info');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const projectName = path.basename(cwd);
|
|
39
|
+
let owner = config.owner;
|
|
40
|
+
|
|
41
|
+
if (!owner) {
|
|
42
|
+
try {
|
|
43
|
+
owner = execSync('gh api user -q .login', { encoding: 'utf8' }).trim();
|
|
44
|
+
} catch (e) {
|
|
45
|
+
owner = 'unknown';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!fs.existsSync(path.join(cwd, 'CHANGELOG.md'))) {
|
|
50
|
+
const changelog = `# Changelog\n\n## [0.0.1] - ${new Date().toISOString().split('T')[0]}\n\n### Added\n- Initial project setup\n`;
|
|
51
|
+
await fs.writeFile(path.join(cwd, 'CHANGELOG.md'), changelog);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!fs.existsSync(path.join(cwd, 'README.md'))) {
|
|
55
|
+
const readme = `# ${projectName}\n\nProject created with @a5gard/asgard\n`;
|
|
56
|
+
await fs.writeFile(path.join(cwd, 'README.md'), readme);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!fs.existsSync(path.join(cwd, 'LICENSE.md'))) {
|
|
60
|
+
const licenseContent = getLicenseContent('MIT', owner);
|
|
61
|
+
await fs.writeFile(path.join(cwd, 'LICENSE.md'), licenseContent);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!fs.existsSync(configPath)) {
|
|
65
|
+
await fs.writeJson(configPath, {
|
|
66
|
+
repo: projectName,
|
|
67
|
+
owner: owner,
|
|
68
|
+
branch: targetBranch,
|
|
69
|
+
license: 'MIT',
|
|
70
|
+
autoPushRepo: true,
|
|
71
|
+
packageManager: 'pnpm'
|
|
72
|
+
}, { spaces: 2 });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
spinner.stop();
|
|
76
|
+
boxLine('Project prepared', 'success');
|
|
77
|
+
|
|
78
|
+
let isRepo = true;
|
|
79
|
+
try {
|
|
80
|
+
execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
|
|
81
|
+
} catch (e) {
|
|
82
|
+
isRepo = false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!isRepo) {
|
|
86
|
+
spinner.text = `Initializing git repository...`;
|
|
87
|
+
spinner.start();
|
|
88
|
+
execSync('git init', { cwd });
|
|
89
|
+
execSync(`git checkout -b ${targetBranch}`, { cwd });
|
|
90
|
+
execSync('git add .', { cwd });
|
|
91
|
+
execSync('git commit -m "Initial commit"', { cwd });
|
|
92
|
+
spinner.stop();
|
|
93
|
+
boxLine(`Git repository initialized on ${targetBranch}`, 'success');
|
|
94
|
+
} else {
|
|
95
|
+
try {
|
|
96
|
+
execSync(`git branch -M ${targetBranch}`, { cwd });
|
|
97
|
+
} catch (e) {}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let hasCommits = false;
|
|
101
|
+
try {
|
|
102
|
+
execSync('git rev-parse HEAD', { stdio: 'ignore', cwd });
|
|
103
|
+
hasCommits = true;
|
|
104
|
+
} catch (e) {
|
|
105
|
+
hasCommits = false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (!hasCommits) {
|
|
109
|
+
spinner.text = 'Creating initial commit...';
|
|
110
|
+
spinner.start();
|
|
111
|
+
execSync('git add .', { cwd });
|
|
112
|
+
execSync('git commit -m "Initial commit"', { cwd });
|
|
113
|
+
spinner.stop();
|
|
114
|
+
boxLine('Initial commit created', 'success');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
spinner.text = 'Syncing with GitHub...';
|
|
118
|
+
spinner.start();
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
execSync(`gh repo create ${projectName} --private --source=. --push`, {
|
|
122
|
+
cwd,
|
|
123
|
+
stdio: 'pipe'
|
|
124
|
+
});
|
|
125
|
+
spinner.stop();
|
|
126
|
+
boxLine('GitHub repository created and project pushed', 'success');
|
|
127
|
+
} catch (error) {
|
|
128
|
+
const errorMsg = error.stderr ? error.stderr.toString() : error.message;
|
|
129
|
+
|
|
130
|
+
if (errorMsg.includes('already exists')) {
|
|
131
|
+
spinner.stop();
|
|
132
|
+
boxLine(`Repository exists, forcing push to ${targetBranch}...`, 'warning');
|
|
133
|
+
spinner.start();
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
execSync(`git remote add origin https://github.com/${owner}/${projectName}.git`, { cwd, stdio: 'ignore' });
|
|
137
|
+
} catch (e) {
|
|
138
|
+
execSync(`git remote set-url origin https://github.com/${owner}/${projectName}.git`, { cwd });
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
execSync(`git push -u origin ${targetBranch} --force`, { cwd, stdio: 'pipe' });
|
|
142
|
+
spinner.stop();
|
|
143
|
+
boxLine('Project pushed to existing repository', 'success');
|
|
144
|
+
} else {
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
boxDivider();
|
|
150
|
+
boxEnd(true, 'Project published successfully');
|
|
151
|
+
} catch (error) {
|
|
152
|
+
spinner.stop();
|
|
153
|
+
const msg = error.stderr ? error.stderr.toString() : error.message;
|
|
154
|
+
|
|
155
|
+
if (msg.includes('gh: not found') || msg.includes('is not recognized')) {
|
|
156
|
+
boxLine('Error: GitHub CLI (gh) is required.', 'error');
|
|
157
|
+
boxLine('Install it from: https://cli.github.com/');
|
|
158
|
+
} else {
|
|
159
|
+
boxLine(msg, 'error');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
boxDivider();
|
|
163
|
+
boxEnd(false, 'Publish failed');
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
import { ux } from '@oclif/core';
|
|
4
|
+
import ora from 'ora';
|
|
5
|
+
import { boxStart, boxDivider, boxEnd, boxLine } from '../utils/box.js';
|
|
6
|
+
|
|
7
|
+
export default class ReplaceTimeline extends Command {
|
|
8
|
+
static description = 'Merge branch into main and delete source';
|
|
9
|
+
|
|
10
|
+
static flags = {
|
|
11
|
+
branch: Flags.string({ char: 'b', description: 'Branch to merge and delete' })
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
async run() {
|
|
15
|
+
const cwd = process.cwd();
|
|
16
|
+
boxStart('Replace Timeline');
|
|
17
|
+
|
|
18
|
+
const { flags } = await this.parse(ReplaceTimeline);
|
|
19
|
+
let branchName = flags.branch;
|
|
20
|
+
|
|
21
|
+
const spinner = ora('Loading branches...').start();
|
|
22
|
+
|
|
23
|
+
const current = execSync('git branch --show-current', { cwd, encoding: 'utf8' }).trim();
|
|
24
|
+
|
|
25
|
+
if (current !== 'main') {
|
|
26
|
+
spinner.stop();
|
|
27
|
+
boxLine('Must be on main branch', 'warning');
|
|
28
|
+
boxDivider();
|
|
29
|
+
boxEnd(false, 'Not on main branch');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const branchListRaw = execSync('git branch --format="%(refname:short)"', { cwd, encoding: 'utf8' });
|
|
34
|
+
const mergeable = branchListRaw.split('\n').map(b => b.trim()).filter(b => b && b !== 'main');
|
|
35
|
+
|
|
36
|
+
spinner.stop();
|
|
37
|
+
|
|
38
|
+
if (mergeable.length === 0) {
|
|
39
|
+
boxLine('No branches available to merge', 'warning');
|
|
40
|
+
boxDivider();
|
|
41
|
+
boxEnd(false, 'No mergeable branches');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!branchName) {
|
|
46
|
+
boxLine('Please select a branch to merge and delete:');
|
|
47
|
+
boxDivider();
|
|
48
|
+
|
|
49
|
+
branchName = await ux.select({
|
|
50
|
+
message: 'Select branch to merge and delete',
|
|
51
|
+
options: mergeable.map(b => ({ label: b, value: b }))
|
|
52
|
+
});
|
|
53
|
+
boxDivider();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const mergeSpinner = ora('Merging...').start();
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
execSync(`git merge ${branchName} --no-edit`, { cwd, stdio: 'pipe' });
|
|
60
|
+
|
|
61
|
+
mergeSpinner.text = 'Deleting branch...';
|
|
62
|
+
execSync(`git branch -d ${branchName}`, { cwd, stdio: 'pipe' });
|
|
63
|
+
|
|
64
|
+
mergeSpinner.stop();
|
|
65
|
+
boxLine(`Merged and deleted '${branchName}'`, 'success');
|
|
66
|
+
boxDivider();
|
|
67
|
+
boxEnd(true, 'Complete');
|
|
68
|
+
} catch (error) {
|
|
69
|
+
mergeSpinner.stop();
|
|
70
|
+
const msg = error.stderr ? error.stderr.toString() : error.message;
|
|
71
|
+
boxLine(msg, 'error');
|
|
72
|
+
boxDivider();
|
|
73
|
+
boxEnd(false, 'Operation failed');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
import { ux } from '@oclif/core';
|
|
4
|
+
import ora from 'ora';
|
|
5
|
+
import { boxStart, boxDivider, boxEnd, boxLine } from '../utils/box.js';
|
|
6
|
+
|
|
7
|
+
export default class ReplaceTimeline extends Command {
|
|
8
|
+
static description = 'Merge branch into main and delete source';
|
|
9
|
+
|
|
10
|
+
static flags = {
|
|
11
|
+
branch: Flags.string({ char: 'b', description: 'Branch to merge and delete' })
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
async run() {
|
|
15
|
+
const cwd = process.cwd();
|
|
16
|
+
boxStart('Replace Timeline');
|
|
17
|
+
|
|
18
|
+
const { flags } = await this.parse(ReplaceTimeline);
|
|
19
|
+
let branchName = flags.branch;
|
|
20
|
+
|
|
21
|
+
const spinner = ora('Loading branches...').start();
|
|
22
|
+
|
|
23
|
+
// Get current branch
|
|
24
|
+
const current = execSync('git branch --show-current', { cwd, encoding: 'utf8' }).trim();
|
|
25
|
+
|
|
26
|
+
if (current !== 'main') {
|
|
27
|
+
spinner.stop();
|
|
28
|
+
boxLine('Must be on main branch', 'warning');
|
|
29
|
+
boxDivider();
|
|
30
|
+
boxEnd(false, 'Not on main branch');
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Get all local branches except main
|
|
35
|
+
const branchListRaw = execSync('git branch --format="%(refname:short)"', { cwd, encoding: 'utf8' });
|
|
36
|
+
const mergeable = branchListRaw.split('\n').map(b => b.trim()).filter(b => b && b !== 'main');
|
|
37
|
+
|
|
38
|
+
spinner.stop();
|
|
39
|
+
|
|
40
|
+
if (mergeable.length === 0) {
|
|
41
|
+
boxLine('No branches available to merge', 'warning');
|
|
42
|
+
boxDivider();
|
|
43
|
+
boxEnd(false, 'No mergeable branches');
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!branchName) {
|
|
48
|
+
boxLine('Please select a branch to merge and delete:');
|
|
49
|
+
boxDivider();
|
|
50
|
+
|
|
51
|
+
branchName = await ux.select({
|
|
52
|
+
message: 'Select branch to merge and delete',
|
|
53
|
+
options: mergeable.map(b => ({ label: b, value: b }))
|
|
54
|
+
});
|
|
55
|
+
boxDivider();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const mergeSpinner = ora('Merging...').start();
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
// Perform the merge
|
|
62
|
+
execSync(`git merge ${branchName} --no-edit`, { cwd, stdio: 'pipe' });
|
|
63
|
+
|
|
64
|
+
mergeSpinner.text = 'Deleting branch...';
|
|
65
|
+
// Delete the branch locally
|
|
66
|
+
execSync(`git branch -d ${branchName}`, { cwd, stdio: 'pipe' });
|
|
67
|
+
|
|
68
|
+
mergeSpinner.stop();
|
|
69
|
+
boxLine(`Merged and deleted '${branchName}'`, 'success');
|
|
70
|
+
boxDivider();
|
|
71
|
+
boxEnd(true, 'Complete');
|
|
72
|
+
} catch (error) {
|
|
73
|
+
mergeSpinner.stop();
|
|
74
|
+
const msg = error.stderr ? error.stderr.toString() : error.message;
|
|
75
|
+
boxLine(msg, 'error');
|
|
76
|
+
boxDivider();
|
|
77
|
+
boxEnd(false, 'Operation failed');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import inquirer from 'inquirer';
|
|
3
|
+
import { addCommitPush } from '../git/helpers.js';
|
|
4
|
+
import { boxStart, boxDivider, boxEnd, boxLine } from '../utils/box.js';
|
|
5
|
+
|
|
6
|
+
export default class Save extends Command {
|
|
7
|
+
static description = 'Add, commit, and push changes in one command';
|
|
8
|
+
|
|
9
|
+
static flags = {
|
|
10
|
+
message: Flags.string({ char: 'm', description: 'Commit message' }),
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
async run() {
|
|
14
|
+
boxStart('Save Changes');
|
|
15
|
+
|
|
16
|
+
const { flags } = await this.parse(Save);
|
|
17
|
+
let message = flags.message;
|
|
18
|
+
|
|
19
|
+
if (!message) {
|
|
20
|
+
boxLine('Commit and push your changes to the remote repository.');
|
|
21
|
+
boxDivider();
|
|
22
|
+
|
|
23
|
+
const response = await inquirer.prompt([
|
|
24
|
+
{
|
|
25
|
+
type: 'input',
|
|
26
|
+
name: 'message',
|
|
27
|
+
message: 'Enter commit message:',
|
|
28
|
+
prefix: '',
|
|
29
|
+
suffix: '',
|
|
30
|
+
validate: input => input.trim().length > 0 || 'Commit message cannot be empty',
|
|
31
|
+
},
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
message = response.message;
|
|
35
|
+
boxDivider();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
await addCommitPush(message);
|
|
40
|
+
boxDivider();
|
|
41
|
+
boxEnd(true, 'Complete');
|
|
42
|
+
} catch (error) {
|
|
43
|
+
boxLine(error.message, 'error');
|
|
44
|
+
boxDivider();
|
|
45
|
+
boxEnd(false, 'Save failed');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
import { ux } from '@oclif/core';
|
|
4
|
+
import ora from 'ora';
|
|
5
|
+
import { boxStart, boxDivider, boxEnd, boxLine } from '../utils/box.js';
|
|
6
|
+
|
|
7
|
+
export default class SetSource extends Command {
|
|
8
|
+
static description = 'Replace remote URL';
|
|
9
|
+
|
|
10
|
+
static flags = {
|
|
11
|
+
remote: Flags.string({ char: 'r', description: 'Remote name' }),
|
|
12
|
+
url: Flags.string({ char: 'u', description: 'New URL', required: true })
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
async run() {
|
|
16
|
+
const cwd = process.cwd();
|
|
17
|
+
boxStart('Set Source');
|
|
18
|
+
|
|
19
|
+
const { flags } = await this.parse(SetSource);
|
|
20
|
+
let remoteName = flags.remote;
|
|
21
|
+
|
|
22
|
+
if (!remoteName) {
|
|
23
|
+
boxLine('Please select a remote to update:');
|
|
24
|
+
boxDivider();
|
|
25
|
+
|
|
26
|
+
let remotes = [];
|
|
27
|
+
try {
|
|
28
|
+
const remoteRaw = execSync('git remote', { cwd, encoding: 'utf8' }).trim();
|
|
29
|
+
remotes = remoteRaw ? remoteRaw.split('\n') : [];
|
|
30
|
+
} catch (e) {
|
|
31
|
+
remotes = [];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (remotes.length === 0) {
|
|
35
|
+
boxLine('No remotes found', 'warning');
|
|
36
|
+
boxDivider();
|
|
37
|
+
boxEnd(false, 'Operation aborted');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
remoteName = await ux.select({
|
|
42
|
+
message: 'Select remote to update',
|
|
43
|
+
options: remotes.map(r => ({ label: r, value: r }))
|
|
44
|
+
});
|
|
45
|
+
boxDivider();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const spinner = ora('Updating remote...').start();
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
execSync(`git remote set-url ${remoteName} ${flags.url}`, { cwd, stdio: 'pipe' });
|
|
52
|
+
spinner.stop();
|
|
53
|
+
boxLine(`Remote '${remoteName}' updated to:`, 'success');
|
|
54
|
+
boxLine(flags.url);
|
|
55
|
+
boxDivider();
|
|
56
|
+
boxEnd(true, 'Complete');
|
|
57
|
+
} catch (error) {
|
|
58
|
+
spinner.stop();
|
|
59
|
+
const msg = error.stderr ? error.stderr.toString() : error.message;
|
|
60
|
+
boxLine(msg, 'error');
|
|
61
|
+
boxDivider();
|
|
62
|
+
boxEnd(false, 'Failed to update remote');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
import { ux } from '@oclif/core';
|
|
4
|
+
import ora from 'ora';
|
|
5
|
+
import { boxStart, boxDivider, boxEnd, boxLine } from '../utils/box.js';
|
|
6
|
+
import { syncRepo } from '../git/sync-repo.js';
|
|
7
|
+
|
|
8
|
+
export default class SwitchTimeline extends Command {
|
|
9
|
+
static description = 'Switch branches';
|
|
10
|
+
|
|
11
|
+
static flags = {
|
|
12
|
+
branch: Flags.string({ char: 'b', description: 'Branch name' })
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
async run() {
|
|
16
|
+
const cwd = process.cwd();
|
|
17
|
+
boxStart('Switch Timeline');
|
|
18
|
+
|
|
19
|
+
await syncRepo();
|
|
20
|
+
const { flags } = await this.parse(SwitchTimeline);
|
|
21
|
+
let branchName = flags.branch;
|
|
22
|
+
|
|
23
|
+
if (!branchName) {
|
|
24
|
+
const spinner = ora('Loading branches...').start();
|
|
25
|
+
|
|
26
|
+
let branches = [];
|
|
27
|
+
try {
|
|
28
|
+
const branchListRaw = execSync('git branch --format="%(refname:short)"', { cwd, encoding: 'utf8' });
|
|
29
|
+
branches = branchListRaw.split('\n').map(b => b.trim()).filter(Boolean);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
// Not a git repo or no branches
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
spinner.stop();
|
|
35
|
+
|
|
36
|
+
if (branches.length === 0) {
|
|
37
|
+
boxLine('No branches found', 'warning');
|
|
38
|
+
boxDivider();
|
|
39
|
+
boxEnd(false, 'Operation aborted');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
boxLine('Please select a branch to switch to:');
|
|
44
|
+
boxDivider();
|
|
45
|
+
|
|
46
|
+
branchName = await ux.select({
|
|
47
|
+
message: 'Select branch',
|
|
48
|
+
options: branches.map(b => ({ label: b, value: b }))
|
|
49
|
+
});
|
|
50
|
+
boxDivider();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const switchSpinner = ora(`Switching to ${branchName}...`).start();
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
execSync(`git checkout ${branchName}`, { cwd, stdio: 'pipe' });
|
|
57
|
+
switchSpinner.stop();
|
|
58
|
+
boxLine(`Switched to '${branchName}'`, 'success');
|
|
59
|
+
boxDivider();
|
|
60
|
+
boxEnd(true, 'Complete');
|
|
61
|
+
} catch (error) {
|
|
62
|
+
switchSpinner.stop();
|
|
63
|
+
const msg = error.stderr ? error.stderr.toString() : error.message;
|
|
64
|
+
boxLine(msg, 'error');
|
|
65
|
+
boxDivider();
|
|
66
|
+
boxEnd(false, 'Failed to switch branch');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { syncRepo } from '../git/sync-repo.js';
|
|
5
|
+
import { boxStart, boxDivider, boxEnd, boxLine } from '../utils/box.js';
|
|
6
|
+
|
|
7
|
+
export default class SyncBeforePush extends Command {
|
|
8
|
+
async run() {
|
|
9
|
+
|
|
10
|
+
boxStart('Upload project to source');
|
|
11
|
+
|
|
12
|
+
const spinner = ora('Syncing with remote...').start();
|
|
13
|
+
const cwd = process.cwd();
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
await syncRepo();
|
|
17
|
+
|
|
18
|
+
spinner.stop();
|
|
19
|
+
boxLine('Synced with remote', 'success');
|
|
20
|
+
boxDivider();
|
|
21
|
+
boxEnd(true, 'Complete');
|
|
22
|
+
return true;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
spinner.stop();
|
|
25
|
+
const msg = error.stderr ? error.stderr.toString() : error.message;
|
|
26
|
+
boxLine(msg, 'error');
|
|
27
|
+
boxDivider();
|
|
28
|
+
boxEnd(false, 'Sync failed');
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { bumpVersion } from '../git/helpers.js';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { boxStart, boxDivider, boxEnd, boxLine } from '../utils/box.js';
|
|
5
|
+
import { syncRepo } from '../git/sync-repo.js';
|
|
6
|
+
|
|
7
|
+
export default class UploadProjectMajor extends Command {
|
|
8
|
+
static description = 'Push and bump major version';
|
|
9
|
+
|
|
10
|
+
async run() {
|
|
11
|
+
boxStart('Upload Project Major');
|
|
12
|
+
|
|
13
|
+
const spinner = ora('Preparing upload...').start();
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
await syncRepo();
|
|
17
|
+
spinner.stop();
|
|
18
|
+
boxLine('Synced with remote', 'success');
|
|
19
|
+
|
|
20
|
+
spinner.text = 'Bumping version...';
|
|
21
|
+
spinner.start();
|
|
22
|
+
await bumpVersion('major');
|
|
23
|
+
spinner.stop();
|
|
24
|
+
boxLine(`Version bumped`, 'success');
|
|
25
|
+
boxDivider();
|
|
26
|
+
boxEnd(true, `Upload complete `);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
spinner.stop();
|
|
29
|
+
boxLine(error.message, 'error');
|
|
30
|
+
boxDivider();
|
|
31
|
+
boxEnd(false, 'Upload failed');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { bumpVersion } from '../git/helpers.js';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { boxStart, boxDivider, boxEnd, boxLine } from '../utils/box.js';
|
|
5
|
+
import { syncRepo } from '../git/sync-repo.js';
|
|
6
|
+
|
|
7
|
+
export default class UploadProjectMinor extends Command {
|
|
8
|
+
static description = 'Push and bump minor version';
|
|
9
|
+
|
|
10
|
+
async run() {
|
|
11
|
+
boxStart('Upload Project Minor');
|
|
12
|
+
const spinner = ora('Preparing upload...').start();
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
await syncRepo();
|
|
16
|
+
spinner.stop();
|
|
17
|
+
boxLine('Synced with remote', 'success');
|
|
18
|
+
|
|
19
|
+
spinner.text = 'Bumping version...';
|
|
20
|
+
spinner.start();
|
|
21
|
+
await bumpVersion('minor');
|
|
22
|
+
spinner.stop();
|
|
23
|
+
boxLine(`Version bumped`, 'success');
|
|
24
|
+
|
|
25
|
+
boxDivider();
|
|
26
|
+
boxEnd(true, `Upload complete`);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
spinner.stop();
|
|
29
|
+
const msg = error.stderr ? error.stderr.toString() : error.message;
|
|
30
|
+
boxLine(msg, 'error');
|
|
31
|
+
boxDivider();
|
|
32
|
+
boxEnd(false, 'Upload failed');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { bumpVersion } from '../git/helpers.js';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { boxStart, boxDivider, boxEnd, boxLine } from '../utils/box.js';
|
|
5
|
+
import { syncRepo } from '../git/sync-repo.js';
|
|
6
|
+
import fs from 'fs-extra';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export default class UploadProjectPatch extends Command {
|
|
11
|
+
static description = 'Push and bump patch version';
|
|
12
|
+
|
|
13
|
+
async run() {
|
|
14
|
+
|
|
15
|
+
const configPath = path.join(repoPath, 'config.asgard');
|
|
16
|
+
|
|
17
|
+
let branch = 'main';
|
|
18
|
+
|
|
19
|
+
if (fs.existsSync(configPath)) {
|
|
20
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
21
|
+
branch = config.branch || 'main';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
boxStart('Upload Project Patch');
|
|
25
|
+
|
|
26
|
+
const spinner = ora('Preparing upload...').start();
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
await syncRepo();
|
|
30
|
+
spinner.stop();
|
|
31
|
+
boxLine('Synced with remote', 'success');
|
|
32
|
+
|
|
33
|
+
spinner.text = 'Bumping version...';
|
|
34
|
+
spinner.start();
|
|
35
|
+
await bumpVersion('patch');
|
|
36
|
+
spinner.stop();
|
|
37
|
+
boxLine(`Version bumped`, 'success');
|
|
38
|
+
boxDivider();
|
|
39
|
+
boxEnd(true, `Upload complete `);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
spinner.stop();
|
|
42
|
+
boxLine(error.message, 'error');
|
|
43
|
+
boxDivider();
|
|
44
|
+
boxEnd(false, 'Upload failed');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { boxStart, boxDivider, boxEnd, boxLine } from '../utils/box.js';
|
|
5
|
+
import { syncRepo } from '../git/sync-repo.js';
|
|
6
|
+
|
|
7
|
+
export default class UploadProject extends Command {
|
|
8
|
+
static description = 'Add, commit, and push changes';
|
|
9
|
+
|
|
10
|
+
async run() {
|
|
11
|
+
boxStart('Upload project to source');
|
|
12
|
+
|
|
13
|
+
const spinner = ora('Preparing upload...').start();
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
// Ensure syncRepo is also refactored to use execSync
|
|
17
|
+
await syncRepo();
|
|
18
|
+
|
|
19
|
+
spinner.stop();
|
|
20
|
+
boxLine('Upload complete', 'success');
|
|
21
|
+
boxDivider();
|
|
22
|
+
boxEnd(true, 'Complete');
|
|
23
|
+
} catch (error) {
|
|
24
|
+
spinner.stop();
|
|
25
|
+
const msg = error.stderr ? error.stderr.toString() : error.message;
|
|
26
|
+
boxLine(msg, 'error');
|
|
27
|
+
boxDivider();
|
|
28
|
+
boxEnd(false, 'Upload failed');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|