ft-scout 1.0.7 ā 1.0.8
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/.ft/context.json +11 -9
- package/bin/src/commands/init.d.ts.map +1 -1
- package/bin/src/commands/init.js +148 -30
- package/bin/src/commands/init.js.map +1 -1
- package/bin/src/commands/owners.d.ts.map +1 -1
- package/bin/src/commands/owners.js +44 -1
- package/bin/src/commands/owners.js.map +1 -1
- package/bin/src/index.js +3 -2
- package/bin/src/index.js.map +1 -1
- package/email-template.html +223 -0
- package/email-template.txt +45 -0
- package/package.json +1 -1
- package/scripts/send-brevo-campaign.cjs +167 -0
- package/scripts/send-email.js +77 -0
package/.ft/context.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
"projectName": "
|
|
3
|
-
"
|
|
4
|
-
"
|
|
2
|
+
"projectName": "FrontTerrainApp",
|
|
3
|
+
"repoUrl": "https://github.com/dark2quasar/Front-Terrain/FrontTerrainApp.git",
|
|
4
|
+
"targetDir": "C:\\Users\\rishi\\AppData\\Local\\Temp\\ft-scout-repos\\FrontTerrainApp-1785465176613",
|
|
5
|
+
"stack": "The FrontTerrainApp project is a social media application built with Flutter and React, utilizing Firebase for hosting and backend services. Its core stack includes TypeScript, React, and Flutter, with a mix of JavaScript and Python scripts for specific tasks.",
|
|
6
|
+
"entryPoint": "lib/main.dart",
|
|
5
7
|
"painPoints": [
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"file upload handling with Multer"
|
|
8
|
+
"Complex folder structure with multiple build configurations",
|
|
9
|
+
"Usage of both Flutter and React, potentially leading to inconsistencies in code style and architecture"
|
|
9
10
|
],
|
|
10
11
|
"readOrder": [
|
|
11
|
-
"
|
|
12
|
+
"lib/main.dart",
|
|
12
13
|
"package.json",
|
|
13
|
-
"
|
|
14
|
+
"pubspec.yaml",
|
|
15
|
+
"firebase.json"
|
|
14
16
|
],
|
|
15
|
-
"createdAt": "2026-07-
|
|
17
|
+
"createdAt": "2026-07-31T02:33:02.673Z"
|
|
16
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["init.ts"],"names":[],"mappings":"AAsFA,wBAAsB,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,iBA8LhD"}
|
package/bin/src/commands/init.js
CHANGED
|
@@ -1,49 +1,167 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import os from 'os';
|
|
4
|
-
import { spinner, note } from '@clack/prompts';
|
|
4
|
+
import { spinner, note, password, isCancel } from '@clack/prompts';
|
|
5
5
|
import chalk from 'chalk';
|
|
6
6
|
import { simpleGit } from 'simple-git';
|
|
7
7
|
import { generateRepoSummary } from '../engine/llm.js';
|
|
8
8
|
import { saveContext } from '../utils/config.js';
|
|
9
|
+
function extractNpmPackageName(target) {
|
|
10
|
+
if (target.startsWith('npm:')) {
|
|
11
|
+
return target.slice(4).trim();
|
|
12
|
+
}
|
|
13
|
+
const npmUrlMatch = target.match(/^https?:\/\/(?:www\.)?npmjs\.com\/package\/(@?[^/]+(?:\/[^/]+)?)/i);
|
|
14
|
+
if (npmUrlMatch && npmUrlMatch[1]) {
|
|
15
|
+
return npmUrlMatch[1];
|
|
16
|
+
}
|
|
17
|
+
const isGitOrFile = /^https?:\/\//i.test(target) ||
|
|
18
|
+
/^git@/i.test(target) ||
|
|
19
|
+
target.includes('github.com') ||
|
|
20
|
+
target.includes('gitlab.com') ||
|
|
21
|
+
target.endsWith('.git');
|
|
22
|
+
if (!isGitOrFile) {
|
|
23
|
+
if (/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/i.test(target)) {
|
|
24
|
+
return target;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
async function getNpmRepoUrl(pkgName) {
|
|
30
|
+
try {
|
|
31
|
+
const res = await fetch(`https://registry.npmjs.org/${encodeURIComponent(pkgName)}`);
|
|
32
|
+
if (!res.ok) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const data = (await res.json());
|
|
36
|
+
const repo = data.repository;
|
|
37
|
+
if (!repo)
|
|
38
|
+
return null;
|
|
39
|
+
let url = typeof repo === 'string' ? repo : repo.url;
|
|
40
|
+
if (!url)
|
|
41
|
+
return null;
|
|
42
|
+
url = url.replace(/^git\+/, '');
|
|
43
|
+
url = url.replace(/^git:\/\//, 'https://');
|
|
44
|
+
url = url.replace(/^ssh:\/\/git@github\.com\//, 'https://github.com/');
|
|
45
|
+
url = url.replace(/^git@github\.com:/, 'https://github.com/');
|
|
46
|
+
if (url.startsWith('github:')) {
|
|
47
|
+
url = `https://github.com/${url.replace('github:', '')}.git`;
|
|
48
|
+
}
|
|
49
|
+
if (url.startsWith('gitlab:')) {
|
|
50
|
+
url = `https://gitlab.com/${url.replace('gitlab:', '')}.git`;
|
|
51
|
+
}
|
|
52
|
+
if (url.startsWith('bitbucket:')) {
|
|
53
|
+
url = `https://bitbucket.org/${url.replace('bitbucket:', '')}.git`;
|
|
54
|
+
}
|
|
55
|
+
return url;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function cleanGitHubUrl(targetUrl) {
|
|
62
|
+
if (targetUrl.includes('github.com')) {
|
|
63
|
+
const match = targetUrl.match(/github\.com\/([^/]+(?:\/[^/]+)+)/i);
|
|
64
|
+
if (match && match[1]) {
|
|
65
|
+
let parts = match[1].split('/').filter(Boolean);
|
|
66
|
+
const branchIndex = parts.findIndex((p) => ['tree', 'blob', 'src'].includes(p.toLowerCase()));
|
|
67
|
+
if (branchIndex !== -1) {
|
|
68
|
+
parts = parts.slice(0, branchIndex);
|
|
69
|
+
}
|
|
70
|
+
const cleanParts = parts.map((p, i) => (i === parts.length - 1 ? p.replace(/\.git$/i, '') : p));
|
|
71
|
+
if (cleanParts.length >= 2) {
|
|
72
|
+
const owner = cleanParts[cleanParts.length - 2];
|
|
73
|
+
const repo = cleanParts[cleanParts.length - 1];
|
|
74
|
+
return `https://github.com/${owner}/${repo}.git`;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return targetUrl;
|
|
79
|
+
}
|
|
9
80
|
export async function handleInit(repoUrl) {
|
|
10
81
|
const s = spinner();
|
|
11
82
|
let targetDir = process.cwd();
|
|
12
83
|
if (repoUrl && repoUrl.trim()) {
|
|
13
84
|
const rawTarget = repoUrl.trim();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
85
|
+
const resolvedPath = path.resolve(rawTarget);
|
|
86
|
+
if (fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isDirectory()) {
|
|
87
|
+
targetDir = resolvedPath;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
let gitTargetUrl = cleanGitHubUrl(rawTarget);
|
|
91
|
+
const npmPkgName = extractNpmPackageName(rawTarget);
|
|
92
|
+
const isGitUrl = (/^https?:\/\//i.test(rawTarget) && !rawTarget.includes('npmjs.com')) ||
|
|
93
|
+
/^git@/i.test(rawTarget) ||
|
|
94
|
+
rawTarget.includes('github.com') ||
|
|
95
|
+
rawTarget.includes('gitlab.com') ||
|
|
96
|
+
rawTarget.endsWith('.git');
|
|
97
|
+
if (npmPkgName && !isGitUrl) {
|
|
98
|
+
s.start(`Resolving npm package repository (${chalk.cyan(npmPkgName)})...`);
|
|
99
|
+
const resolvedUrl = await getNpmRepoUrl(npmPkgName);
|
|
100
|
+
if (!resolvedUrl) {
|
|
101
|
+
s.stop(chalk.red(`Failed to resolve npm package repository.`));
|
|
102
|
+
note(chalk.red(`The specified repository is private or does not exist.`), 'ā Invalid Target');
|
|
103
|
+
return;
|
|
27
104
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
s.stop(`Remote repository cloned successfully.`);
|
|
105
|
+
gitTargetUrl = cleanGitHubUrl(resolvedUrl);
|
|
106
|
+
s.stop(`Resolved npm package to repository ${chalk.cyan(gitTargetUrl)}.`);
|
|
31
107
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
108
|
+
s.start(`Cloning remote repository (${chalk.cyan(gitTargetUrl)})...`);
|
|
109
|
+
const repoName = path.basename(gitTargetUrl, '.git') || 'cloned-repo';
|
|
110
|
+
const tempParent = path.join(os.tmpdir(), 'ft-scout-repos');
|
|
111
|
+
targetDir = path.join(tempParent, `${repoName}-${Date.now()}`);
|
|
112
|
+
if (!fs.existsSync(tempParent)) {
|
|
113
|
+
fs.mkdirSync(tempParent, { recursive: true });
|
|
36
114
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isDirectory()) {
|
|
42
|
-
targetDir = resolvedPath;
|
|
115
|
+
const git = simpleGit();
|
|
116
|
+
try {
|
|
117
|
+
await git.clone(gitTargetUrl, targetDir, ['--depth', '1']);
|
|
118
|
+
s.stop(`Remote repository cloned successfully.`);
|
|
43
119
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
120
|
+
catch (err) {
|
|
121
|
+
s.stop(chalk.yellow(`Initial clone failed (repository may be private or require authentication).`));
|
|
122
|
+
// Interactive login / token prompt for private repos
|
|
123
|
+
if (gitTargetUrl.startsWith('https://')) {
|
|
124
|
+
const tokenInput = await password({
|
|
125
|
+
message: 'Enter your GitHub / GitLab Personal Access Token (PAT) to access this private repository:',
|
|
126
|
+
mask: '*',
|
|
127
|
+
validate: (val) => (!val || !val.trim() ? 'Token cannot be empty' : undefined),
|
|
128
|
+
});
|
|
129
|
+
if (!isCancel(tokenInput) && typeof tokenInput === 'string' && tokenInput.trim()) {
|
|
130
|
+
const cleanToken = tokenInput.trim();
|
|
131
|
+
// Inject token into URL: https://<token>@github.com/...
|
|
132
|
+
const authenticatedUrl = gitTargetUrl.replace(/^https:\/\//i, `https://${cleanToken}@`);
|
|
133
|
+
const retrySpinner = spinner();
|
|
134
|
+
retrySpinner.start(`Retrying clone with provided token...`);
|
|
135
|
+
try {
|
|
136
|
+
if (fs.existsSync(targetDir)) {
|
|
137
|
+
fs.rmSync(targetDir, { recursive: true, force: true });
|
|
138
|
+
}
|
|
139
|
+
await git.clone(authenticatedUrl, targetDir, ['--depth', '1']);
|
|
140
|
+
retrySpinner.stop(chalk.green(`Remote repository cloned successfully!`));
|
|
141
|
+
}
|
|
142
|
+
catch (retryErr) {
|
|
143
|
+
retrySpinner.stop(chalk.red(`Authentication failed with the provided token.`));
|
|
144
|
+
note(chalk.red(`Could not clone repository with the provided token.\n` +
|
|
145
|
+
`Please check that your token has repo read permissions.\n\n` +
|
|
146
|
+
`Alternative options:\n` +
|
|
147
|
+
` ⢠Use SSH: ${chalk.cyan('ft init git@github.com:owner/repo.git')}\n` +
|
|
148
|
+
` ⢠Or clone locally first: ${chalk.cyan('ft init ./my-repo-folder')}`), 'ā Authentication Failed');
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
note(chalk.yellow('Login cancelled. Repository initialization aborted.'), 'ā Clone Cancelled');
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
note(chalk.red(`The specified repository is private or does not exist.\n\n` +
|
|
159
|
+
chalk.bold('š How to access private repositories:') + '\n' +
|
|
160
|
+
` ⢠Use SSH URL: ${chalk.cyan('ft init git@github.com:owner/repo.git')}\n` +
|
|
161
|
+
` ⢠Or use PAT Token URL: ${chalk.cyan('ft init https://<TOKEN>@github.com/owner/repo.git')}\n` +
|
|
162
|
+
` ⢠Or clone locally first and run: ${chalk.cyan('ft-scout init ./my-repo-folder')}`), 'ā Clone Error');
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
47
165
|
}
|
|
48
166
|
}
|
|
49
167
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEnE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,SAAS,qBAAqB,CAAC,MAAc;IAC3C,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAChC,CAAC;IACD,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACtG,IAAI,WAAW,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;QAClC,OAAO,WA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ot":"","sources":["owners.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"owners.d.ts","sourceRoot":"","sources":["owners.ts"],"names":[],"mappings":"AAIA,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM,iBAkEpD"}
|
|
@@ -1,2 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
import { spinner, note } from '@clack/prompts';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { getFileOwners } from '../engine/git.js';
|
|
4
|
+
export async function handleOwners(targetPath) {
|
|
5
|
+
const s = spinner();
|
|
6
|
+
s.start(`Analyzing git history for ${chalk.cyan(targetPath)}...`);
|
|
7
|
+
if (!targetPath || !targetPath.trim()) {
|
|
8
|
+
s.stop(chalk.red('No path provided.'));
|
|
9
|
+
note(chalk.red('Please specify a file or directory path, e.g. `ft owners src/index.ts`'), 'š„ File Knowledge Holders');
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (/^https?:\/\//i.test(targetPath) ||
|
|
13
|
+
/^git@/i.test(targetPath) ||
|
|
14
|
+
targetPath.includes('github.com') ||
|
|
15
|
+
targetPath.includes('gitlab.com')) {
|
|
16
|
+
s.stop(chalk.yellow('Remote repository URL detected.'));
|
|
17
|
+
note(`\`ft owners\` is designed for local files and directories (e.g. ${chalk.cyan('ft owners src/index.ts')} or ${chalk.cyan('ft owners .')}).\n\nTo onboard and index a remote repository, please run:\n ${chalk.cyan(`ft init ${targetPath}`)}`, 'š” Usage Tip');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const owners = await getFileOwners(targetPath);
|
|
22
|
+
if (owners.length === 0) {
|
|
23
|
+
s.stop('Ownership analysis complete.');
|
|
24
|
+
note(chalk.yellow(`No commit history found for "${targetPath}". Make sure the file exists and is tracked by Git.`), 'š„ File Knowledge Holders');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
s.stop('Ownership analysis complete.');
|
|
28
|
+
const formattedList = owners
|
|
29
|
+
.map((o, idx) => {
|
|
30
|
+
const rank = chalk.bold(`#${idx + 1}`);
|
|
31
|
+
const pct = chalk.green(`${o.percentage}%`);
|
|
32
|
+
const dateStr = o.lastTouched
|
|
33
|
+
? chalk.dim(`(last active: ${new Date(o.lastTouched).toLocaleDateString()})`)
|
|
34
|
+
: '';
|
|
35
|
+
return ` ${rank} ${chalk.bold(o.author)} ā ${pct} (${o.commits} commit${o.commits > 1 ? 's' : ''}) ${dateStr}`;
|
|
36
|
+
})
|
|
37
|
+
.join('\n');
|
|
38
|
+
note(`Target: ${chalk.bold.cyan(targetPath)}\n\n${chalk.bold('Knowledge Holders:')}\n${formattedList}`, 'š„ File Knowledge Holders');
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
s.stop(chalk.red('Ownership analysis failed.'));
|
|
42
|
+
note(chalk.red(`Could not fetch git history for "${targetPath}". Make sure this is a valid git repository.\nError: ${err?.message || err}`), 'š„ File Knowledge Holders');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
2
45
|
//# sourceMappingURL=owners.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"owners.js","sourceRoot":"","sources":["owners.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"owners.js","sourceRoot":"","sources":["owners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAkB,MAAM,kBAAkB,CAAC;AAEjE,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,UAAkB;IACnD,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,CAAC,CAAC,KAAK,CAAC,6BAA6B,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAElE,IAAI,CAAC,UAAU,I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AC,CAAC;YACvC,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC;YAC5C,MAAM,OAAO,GAAG,CAAC,CAAC,WAAW;gBAC3B,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,iBAAiB,IAAI,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,kBAAkB,EAAE,GAAG,CAAC;gBAC7E,CAAC,CAAC,EAAE,CAAC;YACP,OAAO,IAAI,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,OAAO,UAAU,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,EAAE,CAAC;QACjH,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,IAAI,CACF,WAAW,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,KAAK,aAAa,EAAE,EACjG,2BAA2B,CAC5B,CAAC;IACJ,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC,CAAC;QAChD,IAAI,CACF,KAAK,CAAC,GAAG,CACP,oCAAoC,UAAU,wDAAwD,GAAG,EAAE,OAAO,IAAI,GAAG,EAAE,CAC5H,EACD,2BAA2B,CAC5B,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/bin/src/index.js
CHANGED
|
@@ -18,10 +18,10 @@ program
|
|
|
18
18
|
program
|
|
19
19
|
.name('ft')
|
|
20
20
|
.description('FrontTerrain ā The Onboarding Co-Pilot for New Codebases')
|
|
21
|
-
.version('1.0.
|
|
21
|
+
.version('1.0.8');
|
|
22
22
|
// Header UI on execution
|
|
23
23
|
program.hook('preAction', () => {
|
|
24
|
-
intro(chalk.bgCyan.black(' FrontTerrain CLI (v1.0.
|
|
24
|
+
intro(chalk.bgCyan.black(' FrontTerrain CLI (v1.0.8) '));
|
|
25
25
|
});
|
|
26
26
|
// Command definitions
|
|
27
27
|
program
|
|
@@ -43,6 +43,7 @@ program
|
|
|
43
43
|
.description('Show actual file knowledge holders based on git history')
|
|
44
44
|
.action(async (path) => {
|
|
45
45
|
await handleOwners(path);
|
|
46
|
+
outro(chalk.cyan('File ownership analysis complete.'));
|
|
46
47
|
});
|
|
47
48
|
program.parse(process.argv);
|
|
48
49
|
//# sourceMappingURL=index.js.map
|
package/bin/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,qDAAqD,CAAC;KAClE,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;AAErC,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,kEAAkE,CAAC;KAC/E,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,WAAW,EA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,WAAW,EAAE,CAAC;IACpB,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC,CAAC;AAClD,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,eAAe,CAAC;KACxB,WAAW,CAAC,yDAAyD,CAAC;KACtE,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IACrB,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;IACzB,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC,CAAC;AACzD,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Introducing FrontTerrain (ft-scout)</title>
|
|
7
|
+
<style>
|
|
8
|
+
body {
|
|
9
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
|
10
|
+
background-color: #0f172a;
|
|
11
|
+
margin: 0;
|
|
12
|
+
padding: 40px 12px;
|
|
13
|
+
color: #e2e8f0;
|
|
14
|
+
}
|
|
15
|
+
.container {
|
|
16
|
+
max-width: 620px;
|
|
17
|
+
margin: 0 auto;
|
|
18
|
+
background: #1e293b;
|
|
19
|
+
border-radius: 16px;
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
|
|
22
|
+
border: 1px solid #334155;
|
|
23
|
+
}
|
|
24
|
+
.header {
|
|
25
|
+
background: linear-gradient(135deg, #0284c7 0%, #0d9488 100%);
|
|
26
|
+
padding: 40px 30px;
|
|
27
|
+
text-align: center;
|
|
28
|
+
color: #ffffff;
|
|
29
|
+
}
|
|
30
|
+
.badge {
|
|
31
|
+
display: inline-block;
|
|
32
|
+
background: rgba(255, 255, 255, 0.2);
|
|
33
|
+
color: #ffffff;
|
|
34
|
+
font-size: 11px;
|
|
35
|
+
font-weight: 700;
|
|
36
|
+
padding: 4px 14px;
|
|
37
|
+
border-radius: 20px;
|
|
38
|
+
text-transform: uppercase;
|
|
39
|
+
letter-spacing: 1px;
|
|
40
|
+
margin-bottom: 12px;
|
|
41
|
+
}
|
|
42
|
+
.header h1 {
|
|
43
|
+
margin: 0;
|
|
44
|
+
font-size: 28px;
|
|
45
|
+
font-weight: 800;
|
|
46
|
+
letter-spacing: -0.5px;
|
|
47
|
+
}
|
|
48
|
+
.header p {
|
|
49
|
+
margin-top: 10px;
|
|
50
|
+
color: #e0f2fe;
|
|
51
|
+
font-size: 16px;
|
|
52
|
+
font-weight: 400;
|
|
53
|
+
}
|
|
54
|
+
.content {
|
|
55
|
+
padding: 36px 30px;
|
|
56
|
+
}
|
|
57
|
+
.intro {
|
|
58
|
+
font-size: 16px;
|
|
59
|
+
line-height: 1.7;
|
|
60
|
+
color: #cbd5e1;
|
|
61
|
+
margin-bottom: 28px;
|
|
62
|
+
}
|
|
63
|
+
.section-title {
|
|
64
|
+
font-size: 18px;
|
|
65
|
+
font-weight: 700;
|
|
66
|
+
color: #f8fafc;
|
|
67
|
+
margin-bottom: 16px;
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
}
|
|
71
|
+
.feature-card {
|
|
72
|
+
background: #0f172a;
|
|
73
|
+
border: 1px solid #334155;
|
|
74
|
+
border-radius: 12px;
|
|
75
|
+
padding: 20px;
|
|
76
|
+
margin-bottom: 16px;
|
|
77
|
+
transition: transform 0.2s;
|
|
78
|
+
}
|
|
79
|
+
.feature-header {
|
|
80
|
+
display: flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
margin-bottom: 8px;
|
|
83
|
+
}
|
|
84
|
+
.command-tag {
|
|
85
|
+
background: #0284c7;
|
|
86
|
+
color: #ffffff;
|
|
87
|
+
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
|
|
88
|
+
font-weight: 700;
|
|
89
|
+
font-size: 13px;
|
|
90
|
+
padding: 4px 10px;
|
|
91
|
+
border-radius: 6px;
|
|
92
|
+
margin-right: 10px;
|
|
93
|
+
}
|
|
94
|
+
.feature-name {
|
|
95
|
+
font-weight: 700;
|
|
96
|
+
font-size: 16px;
|
|
97
|
+
color: #f8fafc;
|
|
98
|
+
}
|
|
99
|
+
.feature-desc {
|
|
100
|
+
font-size: 14px;
|
|
101
|
+
color: #94a3b8;
|
|
102
|
+
margin: 0;
|
|
103
|
+
line-height: 1.6;
|
|
104
|
+
}
|
|
105
|
+
.code-box {
|
|
106
|
+
background: #090d16;
|
|
107
|
+
color: #38bdf8;
|
|
108
|
+
padding: 20px;
|
|
109
|
+
border-radius: 10px;
|
|
110
|
+
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
|
|
111
|
+
font-size: 14px;
|
|
112
|
+
line-height: 1.8;
|
|
113
|
+
margin: 28px 0;
|
|
114
|
+
border: 1px solid #1e293b;
|
|
115
|
+
}
|
|
116
|
+
.code-box span.comment {
|
|
117
|
+
color: #64748b;
|
|
118
|
+
}
|
|
119
|
+
.code-box span.cmd {
|
|
120
|
+
color: #4ade80;
|
|
121
|
+
}
|
|
122
|
+
.cta-container {
|
|
123
|
+
text-align: center;
|
|
124
|
+
margin: 36px 0 20px 0;
|
|
125
|
+
}
|
|
126
|
+
.btn {
|
|
127
|
+
background: linear-gradient(135deg, #0284c7 0%, #0d9488 100%);
|
|
128
|
+
color: #ffffff !important;
|
|
129
|
+
padding: 16px 36px;
|
|
130
|
+
border-radius: 10px;
|
|
131
|
+
text-decoration: none;
|
|
132
|
+
font-weight: 700;
|
|
133
|
+
display: inline-block;
|
|
134
|
+
font-size: 16px;
|
|
135
|
+
box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
|
|
136
|
+
}
|
|
137
|
+
.footer {
|
|
138
|
+
background: #0f172a;
|
|
139
|
+
text-align: center;
|
|
140
|
+
padding: 24px;
|
|
141
|
+
font-size: 13px;
|
|
142
|
+
color: #64748b;
|
|
143
|
+
border-top: 1px solid #334155;
|
|
144
|
+
}
|
|
145
|
+
.footer a {
|
|
146
|
+
color: #38bdf8;
|
|
147
|
+
text-decoration: none;
|
|
148
|
+
}
|
|
149
|
+
</style>
|
|
150
|
+
</head>
|
|
151
|
+
<body>
|
|
152
|
+
<div class="container">
|
|
153
|
+
<div class="header">
|
|
154
|
+
<span class="badge">V1.0.8 RELEASE</span>
|
|
155
|
+
<h1>FrontTerrain (<code>ft-scout</code>)</h1>
|
|
156
|
+
<p>The AI Onboarding Co-Pilot for New Codebases</p>
|
|
157
|
+
</div>
|
|
158
|
+
|
|
159
|
+
<div class="content">
|
|
160
|
+
<p class="intro">
|
|
161
|
+
Hey FrontTerrain Developer š,<br><br>
|
|
162
|
+
Jumping into a massive or legacy codebase can be intimidating. You waste hours deciphering complex file structures, guessing who owns which module, or accidentally editing fragile hotspots.<br><br>
|
|
163
|
+
Thatās why we built <strong><code>ft-scout</code> (FrontTerrain CLI)</strong> ā your AI co-pilot designed to give you instant codebase clarity directly inside your terminal!
|
|
164
|
+
</p>
|
|
165
|
+
|
|
166
|
+
<div class="section-title">ā” What You Can Do with <code>ft-scout</code>:</div>
|
|
167
|
+
|
|
168
|
+
<div class="feature-card">
|
|
169
|
+
<div class="feature-header">
|
|
170
|
+
<span class="command-tag">ft brief</span>
|
|
171
|
+
<span class="feature-name">AI Onboarding Summary</span>
|
|
172
|
+
</div>
|
|
173
|
+
<p class="feature-desc">Get an instant, human-readable summary of repository architecture, tech stack, and key modules so you can start contributing immediately.</p>
|
|
174
|
+
</div>
|
|
175
|
+
|
|
176
|
+
<div class="feature-card">
|
|
177
|
+
<div class="feature-header">
|
|
178
|
+
<span class="command-tag">ft risky</span>
|
|
179
|
+
<span class="feature-name">Code Fragility Risk Map</span>
|
|
180
|
+
</div>
|
|
181
|
+
<p class="feature-desc">Analyzes commit churn, hotfixes, and historical regressions to alert you about high-risk hotspots and line ranges before you touch them.</p>
|
|
182
|
+
</div>
|
|
183
|
+
|
|
184
|
+
<div class="feature-card">
|
|
185
|
+
<div class="feature-header">
|
|
186
|
+
<span class="command-tag">ft owners <path></span>
|
|
187
|
+
<span class="feature-name">Domain Knowledge Holders</span>
|
|
188
|
+
</div>
|
|
189
|
+
<p class="feature-desc">Identifies true code experts based on real commit frequency and authorshipāso you know exactly who to loop into code reviews.</p>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<div class="feature-card">
|
|
193
|
+
<div class="feature-header">
|
|
194
|
+
<span class="command-tag">ft setup</span>
|
|
195
|
+
<span class="feature-name">Local Dev Diagnostic</span>
|
|
196
|
+
</div>
|
|
197
|
+
<p class="feature-desc">Automatically scans missing <code>.env</code> keys, node runtime mismatches, and configuration issues before they break your local build.</p>
|
|
198
|
+
</div>
|
|
199
|
+
|
|
200
|
+
<div class="section-title" style="margin-top: 32px;">š Quick Start Guide</div>
|
|
201
|
+
|
|
202
|
+
<div class="code-box">
|
|
203
|
+
<span class="comment"># 1. Install ft-scout globally via npm</span><br>
|
|
204
|
+
<span class="cmd">npm install -g ft-scout</span><br><br>
|
|
205
|
+
<span class="comment"># 2. Run inside any Git codebase</span><br>
|
|
206
|
+
<span class="cmd">ft init</span><br><br>
|
|
207
|
+
<span class="comment"># 3. Get your onboarding brief & risk map</span><br>
|
|
208
|
+
<span class="cmd">ft brief</span><br>
|
|
209
|
+
<span class="cmd">ft risky</span>
|
|
210
|
+
</div>
|
|
211
|
+
|
|
212
|
+
<div class="cta-container">
|
|
213
|
+
<a href="https://github.com/Front-Terrain/FT-Check#readme" class="btn" target="_blank">Explore Documentation & GitHub</a>
|
|
214
|
+
</div>
|
|
215
|
+
</div>
|
|
216
|
+
|
|
217
|
+
<div class="footer">
|
|
218
|
+
<p>Built with ā¤ļø by Front Terrain</p>
|
|
219
|
+
<p><a href="https://github.com/Front-Terrain/FT-Check">GitHub Repository</a> | <a href="https://github.com/Front-Terrain/FT-Check/issues">Report Issues</a></p>
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
</body>
|
|
223
|
+
</html>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Subject: š Introducing FrontTerrain (ft-scout): Your AI Onboarding Co-Pilot for Codebases
|
|
2
|
+
Preheader: Instant codebase summaries, fragility risk maps, and knowledge owner detection in your terminal.
|
|
3
|
+
|
|
4
|
+
Hey FrontTerrain Developer š,
|
|
5
|
+
|
|
6
|
+
Jumping into a massive or legacy codebase can be intimidating. You waste hours deciphering complex file structures, guessing who owns which module, or accidentally editing fragile hotspots.
|
|
7
|
+
|
|
8
|
+
Thatās why we built ft-scout (FrontTerrain CLI v1.0.7) ā your AI co-pilot designed to give you instant codebase clarity directly inside your terminal!
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
ā” WHAT YOU CAN DO WITH FT-SCOUT:
|
|
13
|
+
|
|
14
|
+
1. ft brief ā AI Onboarding Summary
|
|
15
|
+
Get an instant, human-readable summary of repository architecture, tech stack, and key modules so you can start contributing immediately.
|
|
16
|
+
|
|
17
|
+
2. ft risky ā Code Fragility Risk Map
|
|
18
|
+
Analyzes commit churn, hotfixes, and historical regressions to alert you about high-risk hotspots and line ranges before you touch them.
|
|
19
|
+
|
|
20
|
+
3. ft owners <path> ā Domain Knowledge Holders
|
|
21
|
+
Identifies true code experts based on real commit frequency and authorshipāso you know exactly who to loop into code reviews.
|
|
22
|
+
|
|
23
|
+
4. ft setup ā Local Dev Diagnostic
|
|
24
|
+
Automatically scans missing .env keys, node runtime mismatches, and configuration issues before they break your local build.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
š QUICK START GUIDE:
|
|
29
|
+
|
|
30
|
+
1. Install ft-scout globally via npm:
|
|
31
|
+
$ npm install -g ft-scout
|
|
32
|
+
|
|
33
|
+
2. Run inside any Git codebase:
|
|
34
|
+
$ ft init
|
|
35
|
+
|
|
36
|
+
3. Get your onboarding brief & risk map:
|
|
37
|
+
$ ft brief
|
|
38
|
+
$ ft risky
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
š GitHub & Documentation: https://github.com/Front-Terrain/FT-Check#readme
|
|
43
|
+
|
|
44
|
+
Happy Coding! š
|
|
45
|
+
Front Terrain Team
|
package/package.json
CHANGED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
// Try requiring nodemailer from FrontTerrain if not in current node_modules
|
|
5
|
+
let nodemailer;
|
|
6
|
+
try {
|
|
7
|
+
nodemailer = require('nodemailer');
|
|
8
|
+
} catch {
|
|
9
|
+
try {
|
|
10
|
+
nodemailer = require('C:/Users/rishi/FrontTerrain/node_modules/nodemailer');
|
|
11
|
+
} catch {
|
|
12
|
+
nodemailer = require('C:/Users/rishi/FrontTerrain/functions/node_modules/nodemailer');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Try requiring firebase-admin from FrontTerrain
|
|
17
|
+
let admin;
|
|
18
|
+
try {
|
|
19
|
+
admin = require('firebase-admin');
|
|
20
|
+
} catch {
|
|
21
|
+
try {
|
|
22
|
+
admin = require('C:/Users/rishi/FrontTerrain/node_modules/firebase-admin');
|
|
23
|
+
} catch {
|
|
24
|
+
admin = require('C:/Users/rishi/FrontTerrain/functions/node_modules/firebase-admin');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const serviceAccountPath = 'C:/Users/rishi/FrontTerrain/ServiceAccountKey.json';
|
|
29
|
+
|
|
30
|
+
const BREVO_USER = 'b23077001@smtp-brevo.com';
|
|
31
|
+
const BREVO_PASS = 'xsmtpsib-63ad84e2307ca830b499c8921f1a242cab01b6f938119cf453e81ab854f643a3-RLpSOgjpmtGZN1NT';
|
|
32
|
+
const FROM_EMAIL = '"FrontTerrain" <noreply@frontterrain.com>';
|
|
33
|
+
const SUBJECT = 'š Introducing FrontTerrain (ft-scout): Your AI Onboarding Co-Pilot for Codebases';
|
|
34
|
+
|
|
35
|
+
const htmlPath = path.join(__dirname, '../email-template.html');
|
|
36
|
+
const textPath = path.join(__dirname, '../email-template.txt');
|
|
37
|
+
|
|
38
|
+
const htmlContent = fs.readFileSync(htmlPath, 'utf8');
|
|
39
|
+
const textContent = fs.readFileSync(textPath, 'utf8');
|
|
40
|
+
|
|
41
|
+
const transporter = nodemailer.createTransport({
|
|
42
|
+
host: 'smtp-relay.brevo.com',
|
|
43
|
+
port: 587,
|
|
44
|
+
secure: false,
|
|
45
|
+
auth: {
|
|
46
|
+
user: BREVO_USER,
|
|
47
|
+
pass: BREVO_PASS,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
async function getAllUserEmails() {
|
|
52
|
+
const emails = new Set();
|
|
53
|
+
|
|
54
|
+
if (fs.existsSync(serviceAccountPath)) {
|
|
55
|
+
try {
|
|
56
|
+
const serviceAccount = require(serviceAccountPath);
|
|
57
|
+
if (!admin.apps.length) {
|
|
58
|
+
admin.initializeApp({
|
|
59
|
+
credential: admin.credential.cert(serviceAccount),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Fetch from Firestore users collection
|
|
64
|
+
const db = admin.firestore();
|
|
65
|
+
const snapshot = await db.collection('users').get();
|
|
66
|
+
snapshot.forEach((doc) => {
|
|
67
|
+
const data = doc.data();
|
|
68
|
+
if (data.email) emails.add(data.email.trim().toLowerCase());
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Fetch from Firebase Auth users list
|
|
72
|
+
let nextPageToken;
|
|
73
|
+
do {
|
|
74
|
+
const listUsersResult = await admin.auth().listUsers(1000, nextPageToken);
|
|
75
|
+
listUsersResult.users.forEach((userRecord) => {
|
|
76
|
+
if (userRecord.email) emails.add(userRecord.email.trim().toLowerCase());
|
|
77
|
+
});
|
|
78
|
+
nextPageToken = listUsersResult.pageToken;
|
|
79
|
+
} while (nextPageToken);
|
|
80
|
+
} catch (err) {
|
|
81
|
+
console.warn('ā ļø Could not fetch users from Firebase:', err.message);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Also check if local users.json exists
|
|
86
|
+
const usersJsonPath = path.join(__dirname, '../users.json');
|
|
87
|
+
if (fs.existsSync(usersJsonPath)) {
|
|
88
|
+
try {
|
|
89
|
+
const localUsers = JSON.parse(fs.readFileSync(usersJsonPath, 'utf8'));
|
|
90
|
+
localUsers.forEach((e) => emails.add(e.trim().toLowerCase()));
|
|
91
|
+
} catch (e) {}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return Array.from(emails);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function main() {
|
|
98
|
+
const args = process.argv.slice(2);
|
|
99
|
+
const isSendMode = args.includes('--send');
|
|
100
|
+
const testEmailArg = args.find((a) => a.startsWith('--test='));
|
|
101
|
+
const testEmail = testEmailArg ? testEmailArg.split('=')[1] : null;
|
|
102
|
+
|
|
103
|
+
console.log('\n=================================================');
|
|
104
|
+
console.log('š FrontTerrain ft-scout Brevo Email Dispatcher');
|
|
105
|
+
console.log('=================================================\n');
|
|
106
|
+
|
|
107
|
+
if (testEmail) {
|
|
108
|
+
console.log(`āļø Sending test email to: ${testEmail}...`);
|
|
109
|
+
const info = await transporter.sendMail({
|
|
110
|
+
from: FROM_EMAIL,
|
|
111
|
+
to: testEmail,
|
|
112
|
+
subject: `${SUBJECT}`,
|
|
113
|
+
html: htmlContent,
|
|
114
|
+
text: textContent,
|
|
115
|
+
});
|
|
116
|
+
console.log(`ā
Test email sent successfully! MessageID: ${info.messageId || info.response}`);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
console.log('š Fetching all FT users...');
|
|
121
|
+
const recipients = await getAllUserEmails();
|
|
122
|
+
console.log(`š Found ${recipients.length} total FT user email address(es):\n`);
|
|
123
|
+
recipients.forEach((email, i) => console.log(` ${i + 1}. ${email}`));
|
|
124
|
+
|
|
125
|
+
if (recipients.length === 0) {
|
|
126
|
+
console.log('\nā ļø No user emails found. Please verify Firebase connection or users.json file.');
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (!isSendMode) {
|
|
131
|
+
console.log('\n-------------------------------------------------');
|
|
132
|
+
console.log('š DRY-RUN MODE (No emails sent).');
|
|
133
|
+
console.log('To send a test email first, run:');
|
|
134
|
+
console.log(' node scripts/send-brevo-campaign.cjs --test=your_email@domain.com\n');
|
|
135
|
+
console.log('To send to ALL users above, run:');
|
|
136
|
+
console.log(' node scripts/send-brevo-campaign.cjs --send');
|
|
137
|
+
console.log('-------------------------------------------------\n');
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
console.log('\nš Starting bulk email dispatch via Brevo SMTP...');
|
|
142
|
+
let successCount = 0;
|
|
143
|
+
let failCount = 0;
|
|
144
|
+
|
|
145
|
+
for (const email of recipients) {
|
|
146
|
+
try {
|
|
147
|
+
const info = await transporter.sendMail({
|
|
148
|
+
from: FROM_EMAIL,
|
|
149
|
+
to: email,
|
|
150
|
+
subject: SUBJECT,
|
|
151
|
+
html: htmlContent,
|
|
152
|
+
text: textContent,
|
|
153
|
+
});
|
|
154
|
+
successCount++;
|
|
155
|
+
console.log(`ā
[${successCount}/${recipients.length}] Sent to ${email} (MessageID: ${info.messageId || info.response})`);
|
|
156
|
+
} catch (err) {
|
|
157
|
+
failCount++;
|
|
158
|
+
console.error(`ā Failed to send to ${email}:`, err.message);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
console.log('\n=================================================');
|
|
163
|
+
console.log(`š Campaign Complete: ${successCount} Sent, ${failCount} Failed.`);
|
|
164
|
+
console.log('=================================================\n');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* FrontTerrain (ft-scout) Email Dispatch Script
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* 1. Set environment variables:
|
|
10
|
+
* export RESEND_API_KEY="re_123456789"
|
|
11
|
+
* (or SENDGRID_API_KEY="SG.xxx")
|
|
12
|
+
* 2. Create `users.json` containing an array of emails:
|
|
13
|
+
* ["user1@example.com", "user2@example.com"]
|
|
14
|
+
* 3. Run: node scripts/send-email.js
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
+
const __dirname = path.dirname(__filename);
|
|
19
|
+
|
|
20
|
+
const htmlTemplatePath = path.join(__dirname, '../email-template.html');
|
|
21
|
+
const textTemplatePath = path.join(__dirname, '../email-template.txt');
|
|
22
|
+
|
|
23
|
+
const htmlContent = fs.readFileSync(htmlTemplatePath, 'utf8');
|
|
24
|
+
const textContent = fs.readFileSync(textTemplatePath, 'utf8');
|
|
25
|
+
|
|
26
|
+
async function sendEmailResend(apiKey, recipients) {
|
|
27
|
+
console.log(`Sending email to ${recipients.length} recipients via Resend API...`);
|
|
28
|
+
|
|
29
|
+
for (const email of recipients) {
|
|
30
|
+
try {
|
|
31
|
+
const response = await fetch('https://api.resend.com/emails', {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
headers: {
|
|
34
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
35
|
+
'Content-Type': 'application/json'
|
|
36
|
+
},
|
|
37
|
+
body: JSON.stringify({
|
|
38
|
+
from: 'FrontTerrain <updates@frontterrain.com>',
|
|
39
|
+
to: [email],
|
|
40
|
+
subject: 'š Introducing FrontTerrain (ft-scout): Your AI Onboarding Co-Pilot',
|
|
41
|
+
html: htmlContent,
|
|
42
|
+
text: textContent
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
const data = await response.json();
|
|
46
|
+
if (response.ok) {
|
|
47
|
+
console.log(`ā
Sent to ${email} (ID: ${data.id})`);
|
|
48
|
+
} else {
|
|
49
|
+
console.error(`ā Failed to send to ${email}:`, data);
|
|
50
|
+
}
|
|
51
|
+
} catch (err) {
|
|
52
|
+
console.error(`ā Error sending to ${email}:`, err.message);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function main() {
|
|
58
|
+
const usersFilePath = path.join(__dirname, '../users.json');
|
|
59
|
+
if (!fs.existsSync(usersFilePath)) {
|
|
60
|
+
console.log('ā¹ļø No users.json file found. Creating example users.json...');
|
|
61
|
+
fs.writeFileSync(usersFilePath, JSON.stringify(["user1@example.com", "user2@example.com"], null, 2));
|
|
62
|
+
console.log('š Please edit `users.json` with your real user emails list.');
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const recipients = JSON.parse(fs.readFileSync(usersFilePath, 'utf8'));
|
|
67
|
+
const resendApiKey = process.env.RESEND_API_KEY;
|
|
68
|
+
|
|
69
|
+
if (resendApiKey) {
|
|
70
|
+
await sendEmailResend(resendApiKey, recipients);
|
|
71
|
+
} else {
|
|
72
|
+
console.log('\nā ļø No API Key detected.');
|
|
73
|
+
console.log('Set `RESEND_API_KEY` or copy the content from `email-template.html` / `email-template.txt` into Mailchimp/SendGrid/Brevo.');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
main().catch(console.error);
|