@staff0rd/assist 0.42.2 → 0.43.0

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 CHANGED
@@ -61,6 +61,7 @@ After installation, the `assist` command will be available globally.
61
61
  - `assist lint init` - Initialize Biome with standard linter config
62
62
  - `assist refactor check [pattern]` - Check for files that exceed the maximum line count
63
63
  - `assist refactor ignore <file>` - Add a file to the refactor ignore list
64
+ - `assist refactor restructure [pattern]` - Analyze import graph and restructure tightly-coupled files into nested directories
64
65
  - `assist devlog list` - Group git commits by date
65
66
  - `assist devlog next` - Show commits for the day after the last versioned entry
66
67
  - `assist devlog skip <date>` - Add a date to the skip list
@@ -1,61 +1,8 @@
1
1
  import { execSync } from "node:child_process";
2
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
- import { dirname, join } from "node:path";
4
- import { fileURLToPath } from "node:url";
5
2
  import chalk from "chalk";
6
3
  import enquirer from "enquirer";
7
4
  import { promptConfirm } from "../../shared/promptConfirm";
8
- import { printDiff } from "../../utils/printDiff";
9
-
10
- const WORKFLOW_PATH = ".github/workflows/build.yml";
11
- const __dirname = dirname(fileURLToPath(import.meta.url));
12
-
13
- function getExistingSiteId(): string | null {
14
- if (!existsSync(WORKFLOW_PATH)) {
15
- return null;
16
- }
17
- const content = readFileSync(WORKFLOW_PATH, "utf-8");
18
- const match = content.match(/-s\s+([a-f0-9-]{36})/);
19
- return match ? match[1] : null;
20
- }
21
-
22
- function getTemplateContent(siteId: string): string {
23
- const templatePath = join(__dirname, "commands/deploy/build.yml");
24
- const template = readFileSync(templatePath, "utf-8");
25
- return template.replace("{{NETLIFY_SITE_ID}}", siteId);
26
- }
27
-
28
- async function updateWorkflow(siteId: string): Promise<void> {
29
- const newContent = getTemplateContent(siteId);
30
-
31
- const workflowDir = ".github/workflows";
32
- if (!existsSync(workflowDir)) {
33
- mkdirSync(workflowDir, { recursive: true });
34
- }
35
-
36
- if (existsSync(WORKFLOW_PATH)) {
37
- const oldContent = readFileSync(WORKFLOW_PATH, "utf-8");
38
-
39
- if (oldContent === newContent) {
40
- console.log(chalk.green("build.yml is already up to date"));
41
- return;
42
- }
43
-
44
- console.log(chalk.yellow("\nbuild.yml will be updated:"));
45
- console.log();
46
- printDiff(oldContent, newContent);
47
-
48
- const confirm = await promptConfirm(chalk.red("Update build.yml?"));
49
-
50
- if (!confirm) {
51
- console.log("Skipped build.yml update");
52
- return;
53
- }
54
- }
55
-
56
- writeFileSync(WORKFLOW_PATH, newContent);
57
- console.log(chalk.green(`\nCreated ${WORKFLOW_PATH}`));
58
- }
5
+ import { getExistingSiteId, updateWorkflow } from "./updateWorkflow";
59
6
 
60
7
  export async function init(): Promise<void> {
61
8
  console.log(chalk.bold("Initializing Netlify deployment...\n"));
@@ -0,0 +1,56 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import chalk from "chalk";
5
+ import { promptConfirm } from "../../shared/promptConfirm";
6
+ import { printDiff } from "../../utils/printDiff";
7
+
8
+ const WORKFLOW_PATH = ".github/workflows/build.yml";
9
+ const __dirname = dirname(fileURLToPath(import.meta.url));
10
+
11
+ export function getExistingSiteId(): string | null {
12
+ if (!existsSync(WORKFLOW_PATH)) {
13
+ return null;
14
+ }
15
+ const content = readFileSync(WORKFLOW_PATH, "utf-8");
16
+ const match = content.match(/-s\s+([a-f0-9-]{36})/);
17
+ return match ? match[1] : null;
18
+ }
19
+
20
+ function getTemplateContent(siteId: string): string {
21
+ const templatePath = join(__dirname, "commands/deploy/build.yml");
22
+ const template = readFileSync(templatePath, "utf-8");
23
+ return template.replace("{{NETLIFY_SITE_ID}}", siteId);
24
+ }
25
+
26
+ export async function updateWorkflow(siteId: string): Promise<void> {
27
+ const newContent = getTemplateContent(siteId);
28
+
29
+ const workflowDir = ".github/workflows";
30
+ if (!existsSync(workflowDir)) {
31
+ mkdirSync(workflowDir, { recursive: true });
32
+ }
33
+
34
+ if (existsSync(WORKFLOW_PATH)) {
35
+ const oldContent = readFileSync(WORKFLOW_PATH, "utf-8");
36
+
37
+ if (oldContent === newContent) {
38
+ console.log(chalk.green("build.yml is already up to date"));
39
+ return;
40
+ }
41
+
42
+ console.log(chalk.yellow("\nbuild.yml will be updated:"));
43
+ console.log();
44
+ printDiff(oldContent, newContent);
45
+
46
+ const confirm = await promptConfirm(chalk.red("Update build.yml?"));
47
+
48
+ if (!confirm) {
49
+ console.log("Skipped build.yml update");
50
+ return;
51
+ }
52
+ }
53
+
54
+ writeFileSync(WORKFLOW_PATH, newContent);
55
+ console.log(chalk.green(`\nCreated ${WORKFLOW_PATH}`));
56
+ }