-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into remote-path-base-dts
- Loading branch information
Showing
410 changed files
with
16,190 additions
and
20,941 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ | |
pnpm-lock.yaml | ||
**/dist/** | ||
apps/website-new/docs | ||
|
||
/.nx/workspace-data | ||
/.nx/cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#!/usr/bin/env node | ||
|
||
const { execSync, execFileSync } = require('child_process'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { OpenAI } = require('openai'); | ||
const yargs = require('yargs/yargs'); | ||
const { hideBin } = require('yargs/helpers'); | ||
const glob = require('glob'); | ||
// Initialize OpenAI client | ||
const openai = new OpenAI({ | ||
apiKey: process.env.OPENAI_API_KEY, | ||
}); | ||
|
||
// Parse command line arguments | ||
const argv = yargs(hideBin(process.argv)) | ||
.option('pattern', { | ||
alias: 'p', | ||
type: 'string', | ||
description: 'Glob pattern to match files', | ||
}) | ||
.option('path', { | ||
alias: 'f', | ||
type: 'string', | ||
description: 'Path to a specific file', | ||
}) | ||
.check((argv) => { | ||
if (!argv.pattern && !argv.path) { | ||
throw new Error('You must provide either a --pattern or --path argument'); | ||
} | ||
return true; | ||
}) | ||
.help() | ||
.alias('help', 'h').argv; | ||
|
||
async function lintFileContent(fileContent) { | ||
const prompt = `Perform safe cleanup and linting on the following file content. | ||
RULES: | ||
-Should preserve uses of normalizeWebpackPath | ||
-Should preserve uses of ts-ignore | ||
-Should improve the source code while ensuing its logic is preserved and functionality is not altered | ||
-Update existing comments for accuracy | ||
-Return only the updated file content with no other response text: | ||
${fileContent}`; | ||
|
||
const response = await openai.chat.completions.create({ | ||
model: 'gpt-4o', | ||
messages: [{ role: 'user', content: prompt }], | ||
max_completion_tokens: 4096, | ||
}); | ||
|
||
let res = response.choices[0].message.content.trim().split('\n'); | ||
if (res[0].startsWith('`')) { | ||
res[0] = undefined; | ||
} | ||
|
||
if (res[res.length - 1].startsWith('`')) { | ||
res[res.length - 1] = undefined; | ||
} | ||
|
||
return res.filter((r) => r).join('\n'); | ||
} | ||
|
||
async function processFile(filePath) { | ||
const fileContent = fs.readFileSync(filePath, 'utf8'); | ||
try { | ||
const lintedContent = await lintFileContent(fileContent); | ||
fs.writeFileSync(filePath, lintedContent, 'utf8'); | ||
console.log(`File has been linted and updated successfully: ${filePath}`); | ||
const tsConfigPath = findTsConfig(filePath); | ||
try { | ||
const tscOutput = execFileSync( | ||
'tsc', | ||
['--noEmit', '--project', tsConfigPath], | ||
{ | ||
stdio: 'pipe', | ||
}, | ||
).toString(); | ||
console.log(`TypeScript check passed for ${filePath}:\n${tscOutput}`); | ||
} catch (error) { | ||
console.error( | ||
`TypeScript check failed for ${filePath}:\n${error.stdout.toString()}`, | ||
); | ||
} | ||
} catch (error) { | ||
console.error(`Error performing linting on ${filePath}:`, error.message); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
function findTsConfig(filePath) { | ||
let dir = path.dirname(filePath); | ||
while (dir !== path.resolve(dir, '..')) { | ||
const tsConfigPath = path.join(dir, 'tsconfig.json'); | ||
if (fs.existsSync(tsConfigPath)) { | ||
return tsConfigPath; | ||
} | ||
dir = path.resolve(dir, '..'); | ||
} | ||
throw new Error('tsconfig.json not found'); | ||
} | ||
|
||
async function main() { | ||
if (argv.path) { | ||
await processFile(argv.path); | ||
} else if (argv.pattern) { | ||
console.log('pattern', argv.pattern); | ||
try { | ||
const files = await glob.glob(argv.pattern); | ||
|
||
for (const filePath of files) { | ||
await processFile(filePath); | ||
} | ||
} catch (err) { | ||
console.error('Error finding files:', err.message); | ||
process.exit(1); | ||
} | ||
} | ||
execSync('nx format:write'); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.