├── blessed-test ├── README.md ├── .gitignore ├── package.json └── src │ ├── progressbar.js │ ├── filemanager.js │ └── table.js ├── my-create-vite ├── .gitignore ├── template-react-ts │ ├── src │ │ ├── vite-env.d.ts │ │ ├── main.tsx │ │ ├── App.css │ │ └── App.tsx │ ├── .DS_Store │ ├── tsconfig.json │ ├── vite.config.ts │ ├── _gitignore │ ├── index.html │ ├── tsconfig.node.json │ ├── tsconfig.app.json │ ├── package.json │ └── eslint.config.js ├── template-vue-ts │ ├── src │ │ ├── vite-env.d.ts │ │ ├── main.ts │ │ ├── assets │ │ │ └── vue.svg │ │ ├── App.vue │ │ └── components │ │ │ └── HelloWorld.vue │ ├── .vscode │ │ └── extensions.json │ ├── .DS_Store │ ├── tsconfig.json │ ├── vite.config.ts │ ├── _gitignore │ ├── index.html │ ├── README.md │ ├── package.json │ ├── tsconfig.node.json │ └── tsconfig.app.json ├── template-vue │ ├── .vscode │ │ └── extensions.json │ ├── .DS_Store │ ├── src │ │ ├── main.js │ │ ├── assets │ │ │ └── vue.svg │ │ ├── App.vue │ │ └── components │ │ │ └── HelloWorld.vue │ ├── vite.config.js │ ├── _gitignore │ ├── README.md │ ├── package.json │ └── index.html ├── .DS_Store ├── template-react │ ├── .DS_Store │ ├── vite.config.js │ ├── src │ │ ├── main.jsx │ │ ├── App.css │ │ └── App.jsx │ ├── _gitignore │ ├── index.html │ ├── README.md │ └── package.json ├── tsconfig.json └── package.json ├── my-prompts ├── .gitignore ├── .DS_Store ├── README.md ├── tsconfig.json ├── package.json ├── .vscode │ └── launch.json └── src │ ├── test2.ts │ └── index.ts ├── stream-test ├── src │ ├── data.txt │ ├── read.mjs │ ├── fsReadStream.mjs │ ├── test2.mjs │ ├── fsWriteStream.mjs │ ├── test.mjs │ ├── zlib.mjs │ ├── socket-client.mjs │ ├── readable.mjs │ ├── readable2.mjs │ ├── socket-server.mjs │ ├── transform.mjs │ ├── writable.mjs │ ├── duplex.mjs │ └── readable3.mjs └── package.json ├── my-git ├── .mygitignore ├── package.json ├── .vscode │ └── launch.json └── src │ ├── init.mjs │ └── cat-file.mjs ├── ansi-test ├── index.js ├── README.md ├── index4.js ├── index2.js ├── package.json ├── index3.js └── index5.js ├── pnpm-monorepo-test ├── README.md ├── .gitignore ├── pnpm-workspace.yaml ├── packages │ ├── core │ │ ├── CHANGELOG.md │ │ ├── src │ │ │ └── index.ts │ │ ├── tsconfig.json │ │ └── package.json │ └── cli │ │ ├── CHANGELOG.md │ │ ├── tsconfig.json │ │ ├── package.json │ │ └── src │ │ └── index.ts ├── .changeset │ ├── config.json │ └── README.md └── package.json ├── guang-cli ├── .gitignore ├── pnpm-workspace.yaml ├── packages │ ├── template-react │ │ ├── template │ │ │ ├── src │ │ │ │ ├── vite-env.d.ts │ │ │ │ ├── main.tsx │ │ │ │ ├── App.css │ │ │ │ └── App.tsx │ │ │ ├── tsconfig.json │ │ │ ├── vite.config.ts │ │ │ ├── .gitignore │ │ │ ├── index.html │ │ │ ├── tsconfig.node.json │ │ │ ├── tsconfig.app.json │ │ │ ├── eslint.config.js │ │ │ └── package.json │ │ ├── questions.json │ │ ├── package.json │ │ └── CHANGELOG.md │ ├── template-vue │ │ ├── template │ │ │ ├── src │ │ │ │ ├── vite-env.d.ts │ │ │ │ ├── main.ts │ │ │ │ ├── assets │ │ │ │ │ └── vue.svg │ │ │ │ ├── App.vue │ │ │ │ └── components │ │ │ │ │ └── HelloWorld.vue │ │ │ ├── .vscode │ │ │ │ └── extensions.json │ │ │ ├── tsconfig.json │ │ │ ├── vite.config.ts │ │ │ ├── .gitignore │ │ │ ├── index.html │ │ │ ├── README.md │ │ │ ├── package.json │ │ │ ├── tsconfig.node.json │ │ │ └── tsconfig.app.json │ │ ├── CHANGELOG.md │ │ └── package.json │ ├── generate │ │ ├── src │ │ │ ├── configType.ts │ │ │ └── test.ts │ │ ├── CHANGELOG.md │ │ ├── tsconfig.json │ │ └── package.json │ ├── utils │ │ ├── src │ │ │ ├── index.ts │ │ │ ├── test.ts │ │ │ └── versionUtils.ts │ │ ├── CHANGELOG.md │ │ ├── tsconfig.json │ │ └── package.json │ ├── cli │ │ ├── tsconfig.json │ │ ├── package.json │ │ ├── src │ │ │ └── index.ts │ │ └── CHANGELOG.md │ └── create │ │ ├── tsconfig.json │ │ ├── CHANGELOG.md │ │ └── package.json ├── .changeset │ ├── config.json │ └── README.md └── package.json ├── rollup-test ├── src │ ├── index.css │ ├── utils.css │ ├── utils.js │ └── index.js ├── README.md ├── package.json ├── webpack.config.mjs ├── my-extract-css-rollup-plugin.mjs └── rollup.config.mjs ├── buffer-test ├── README.md ├── index3.js ├── index5.js ├── package.json ├── index2.js ├── index6.js ├── index.js ├── index4.js ├── index2.html └── index.html ├── my-dns-server ├── REAME.md └── package.json ├── node-api-test ├── path3.js ├── meta.js ├── cp4.mjs ├── child_process.mjs ├── data.db ├── cp3.mjs ├── v8.mjs ├── dns.mjs ├── cluster2.mjs ├── buffer2.mjs ├── fs.mjs ├── vm.mjs ├── crypto.mjs ├── string_decoder.mjs ├── index.html ├── meta2.mjs ├── query_string.mjs ├── util3.mjs ├── crypto3.mjs ├── readline.mjs ├── fs2.mjs ├── path.mjs ├── util.mjs ├── os.mjs ├── fs3.mjs ├── readline3.mjs ├── repl.mjs ├── crypto2.mjs ├── cp2.mjs ├── http-server.mjs ├── cp1.mjs ├── buffer.mjs ├── path2.js ├── worker_threads_worker.mjs ├── worker_threads_main.mjs ├── util4.mjs ├── zlib.mjs ├── package.json ├── events.js ├── net-tcp-client.mjs ├── sqlite.mjs ├── net-tcp-server.mjs ├── util2.mjs ├── url2.mjs ├── readline2.mjs ├── url.mjs ├── fs4.mjs └── cluster.mjs ├── react-comp ├── src │ ├── vite-env.d.ts │ ├── App.tsx │ ├── main.tsx │ ├── Button │ │ ├── index.scss │ │ └── index.tsx │ └── App.css ├── tsconfig.json ├── vite.config.ts ├── .gitignore ├── index.html ├── tsconfig.node.json ├── tsconfig.app.json ├── package.json └── eslint.config.js ├── react-i18n-test ├── README.md ├── src │ ├── vite-env.d.ts │ ├── locales │ │ ├── zh-CN.json │ │ └── en-US.json │ ├── main.tsx │ ├── App.tsx │ └── App.css ├── tsconfig.json ├── vite.config.ts ├── .gitignore ├── index.html ├── tsconfig.node.json ├── tsconfig.app.json ├── package.json └── eslint.config.js ├── scaffold-pkg-test ├── README.md ├── src │ ├── fs-extra.js │ ├── cli-spinner.js │ ├── glob.js │ ├── ora.js │ ├── npminstall.js │ ├── semver.js │ ├── inquirer.mjs │ └── fs.js └── package.json ├── .gitignore ├── blessed-contrib-test ├── README.md ├── package.json └── src │ ├── bar.js │ ├── map.js │ ├── line.js │ ├── gauge.js │ ├── grid.js │ └── line2.js ├── my-comp-lib-test ├── src │ ├── vite-env.d.ts │ ├── main.tsx │ ├── App.tsx │ └── App.css ├── tsconfig.json ├── vite.config.ts ├── .gitignore ├── index.html ├── tsconfig.node.json ├── tsconfig.app.json ├── eslint.config.js ├── package.json └── test.html ├── worker-test ├── README.md ├── page │ ├── worker.js │ ├── index.html │ └── index2.html ├── package.json ├── node │ ├── index.js │ └── node-worker.js └── pool │ └── pool-worker.js ├── cli-args-test ├── README.md ├── index.js ├── index2.js ├── package.json └── index3.js ├── openai-test ├── README.md ├── package.json └── src │ └── system.md ├── .DS_Store ├── ast-transform-test ├── README.md ├── tsconfig.json └── package.json ├── excel-export ├── data.xlsx ├── bundle.xlsx ├── zh-CN.json ├── en-US.json ├── messages.csv ├── message2.csv ├── package.json ├── index.js ├── index3.js └── index5.js ├── exceljs-test ├── data.xlsx ├── data2.xlsx ├── README.md ├── package.json ├── index.js └── index.html ├── keyboard-control ├── src │ ├── test2.ts │ ├── test.ts │ ├── index.ts │ ├── base-ui.ts │ └── list-test.ts ├── README.md ├── tsconfig.json ├── package.json └── .vscode │ └── launch.json ├── my-websocket ├── README.md ├── package.json ├── src │ └── index.js └── index.html ├── scan-thread-pool ├── README.md ├── tsconfig.json ├── package.json └── src │ ├── test.ts │ └── index.ts ├── cli-progress-test ├── .DS_Store ├── README.md ├── tsconfig.json ├── src │ ├── index2.ts │ ├── index.ts │ └── test.ts └── package.json ├── cli-dashboard ├── README.md ├── tsconfig.json ├── test.js ├── .vscode │ └── launch.json └── package.json ├── my-nest-cli ├── nest-project │ └── aaa.module.ts ├── README.md ├── src │ ├── test.ts │ └── cli.ts ├── tsconfig.json └── package.json ├── my-source-map-support ├── README.md ├── src │ └── index.ts ├── test.js ├── tsconfig.json ├── package.json └── .vscode │ └── launch.json ├── react-comp-lib ├── src │ ├── index.ts │ └── Button │ │ ├── index.scss │ │ └── index.tsx ├── tsconfig.json └── package.json ├── sqlite-test ├── src │ ├── index2.mjs │ ├── index4.mjs │ ├── many-many-query.mjs │ ├── index.mjs │ ├── index3.mjs │ └── index5.mjs └── package.json ├── auto-i18n-cli ├── tsconfig.json ├── package.json └── .vscode │ └── launch.json ├── mini-puppeteer ├── src │ ├── lib │ │ └── helpers.mjs │ └── install.mjs └── package.json └── jd-spider ├── package.json └── create-table.js /blessed-test/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /my-create-vite/.gitignore: -------------------------------------------------------------------------------- 1 | dist/ -------------------------------------------------------------------------------- /my-prompts/.gitignore: -------------------------------------------------------------------------------- 1 | nest-app/ -------------------------------------------------------------------------------- /stream-test/src/data.txt: -------------------------------------------------------------------------------- 1 | 神说要有光 2 | -------------------------------------------------------------------------------- /my-git/.mygitignore: -------------------------------------------------------------------------------- 1 | node_modules/** 2 | -------------------------------------------------------------------------------- /ansi-test/index.js: -------------------------------------------------------------------------------- 1 | console.log('123\u001B[1K456') -------------------------------------------------------------------------------- /pnpm-monorepo-test/README.md: -------------------------------------------------------------------------------- 1 | # pnpm monorepo test 2 | -------------------------------------------------------------------------------- /blessed-test/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | *-lock.json 3 | -------------------------------------------------------------------------------- /pnpm-monorepo-test/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .DS_Store -------------------------------------------------------------------------------- /ansi-test/README.md: -------------------------------------------------------------------------------- 1 | # ansi-test 2 | 3 | ansi 控制光标颜色 4 | 5 | -------------------------------------------------------------------------------- /guang-cli/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | .DS_Store 4 | -------------------------------------------------------------------------------- /rollup-test/src/index.css: -------------------------------------------------------------------------------- 1 | .aaa { 2 | background: blue; 3 | } -------------------------------------------------------------------------------- /rollup-test/src/utils.css: -------------------------------------------------------------------------------- 1 | .bbb { 2 | background: red; 3 | } -------------------------------------------------------------------------------- /buffer-test/README.md: -------------------------------------------------------------------------------- 1 | # buffer blob 2 | 3 | node.js 操作二进制数据 4 | -------------------------------------------------------------------------------- /guang-cli/pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - 'packages/*' 3 | -------------------------------------------------------------------------------- /my-dns-server/REAME.md: -------------------------------------------------------------------------------- 1 | # my-dns-server 2 | 3 | node ./src/index.js -------------------------------------------------------------------------------- /node-api-test/path3.js: -------------------------------------------------------------------------------- 1 | const path = require('node:path'); 2 | 3 | -------------------------------------------------------------------------------- /pnpm-monorepo-test/pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - 'packages/*' -------------------------------------------------------------------------------- /ansi-test/index4.js: -------------------------------------------------------------------------------- 1 | console.log('\u001b[36;1;4mguang\u001b[0m 666'); 2 | -------------------------------------------------------------------------------- /node-api-test/meta.js: -------------------------------------------------------------------------------- 1 | console.log(__dirname); 2 | console.log(__filename); -------------------------------------------------------------------------------- /react-comp/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /react-i18n-test/README.md: -------------------------------------------------------------------------------- 1 | # react-i18n-test 2 | 3 | react 项目实现国际化 4 | -------------------------------------------------------------------------------- /scaffold-pkg-test/README.md: -------------------------------------------------------------------------------- 1 | # scaffold-pkg-test 2 | 3 | 脚手架 cli 用到的一些包 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | yarn-* 4 | *-lock.json 5 | .DS_Store -------------------------------------------------------------------------------- /blessed-contrib-test/README.md: -------------------------------------------------------------------------------- 1 | # blessed-contrib-test 2 | 3 | cli 图表库 4 | -------------------------------------------------------------------------------- /my-comp-lib-test/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /react-i18n-test/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /worker-test/README.md: -------------------------------------------------------------------------------- 1 | # node 线程池 2 | 3 | npm install 4 | 5 | node ./pool/index.js -------------------------------------------------------------------------------- /cli-args-test/README.md: -------------------------------------------------------------------------------- 1 | # cli-args-test 2 | 3 | npm install 4 | 5 | node ./index3.js -------------------------------------------------------------------------------- /openai-test/README.md: -------------------------------------------------------------------------------- 1 | # openai-test 2 | 3 | npm install 4 | 5 | node ./src/index.mjs -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkGluonPlasma/nodejs-course-code/HEAD/.DS_Store -------------------------------------------------------------------------------- /my-create-vite/template-react-ts/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /my-create-vite/template-vue-ts/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /node-api-test/cp4.mjs: -------------------------------------------------------------------------------- 1 | import cp from 'node:child_process'; 2 | 3 | cp.fork('./cp1.mjs'); 4 | -------------------------------------------------------------------------------- /node-api-test/child_process.mjs: -------------------------------------------------------------------------------- 1 | import cp from 'node:child_process'; 2 | 3 | console.log(cp); 4 | -------------------------------------------------------------------------------- /react-i18n-test/src/locales/zh-CN.json: -------------------------------------------------------------------------------- 1 | { 2 | "increase": "增加", 3 | "decrease": "减小" 4 | } -------------------------------------------------------------------------------- /guang-cli/packages/template-react/template/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /guang-cli/packages/template-vue/template/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /my-create-vite/template-vue/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["Vue.volar"] 3 | } 4 | -------------------------------------------------------------------------------- /my-create-vite/template-vue-ts/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["Vue.volar"] 3 | } 4 | -------------------------------------------------------------------------------- /react-i18n-test/src/locales/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "increase": "Increase", 3 | "decrease": "Decrease" 4 | } -------------------------------------------------------------------------------- /my-prompts/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkGluonPlasma/nodejs-course-code/HEAD/my-prompts/.DS_Store -------------------------------------------------------------------------------- /node-api-test/data.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkGluonPlasma/nodejs-course-code/HEAD/node-api-test/data.db -------------------------------------------------------------------------------- /ast-transform-test/README.md: -------------------------------------------------------------------------------- 1 | # 基于 AST 实现精准代码修改 2 | 3 | npm install 4 | 5 | npx tsc -w 6 | 7 | node ./dist/index.js -------------------------------------------------------------------------------- /excel-export/data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkGluonPlasma/nodejs-course-code/HEAD/excel-export/data.xlsx -------------------------------------------------------------------------------- /exceljs-test/data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkGluonPlasma/nodejs-course-code/HEAD/exceljs-test/data.xlsx -------------------------------------------------------------------------------- /exceljs-test/data2.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkGluonPlasma/nodejs-course-code/HEAD/exceljs-test/data2.xlsx -------------------------------------------------------------------------------- /guang-cli/packages/template-vue/template/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["Vue.volar"] 3 | } 4 | -------------------------------------------------------------------------------- /keyboard-control/src/test2.ts: -------------------------------------------------------------------------------- 1 | const arr = []; 2 | 3 | while(true){ 4 | arr.push(Math.random()) 5 | } 6 | 7 | -------------------------------------------------------------------------------- /my-websocket/README.md: -------------------------------------------------------------------------------- 1 | # 手写 WebSocket 协议 2 | 3 | npx http-server . 跑静态服务 4 | 5 | node ./src/index.js 跑 node 服务 6 | -------------------------------------------------------------------------------- /scaffold-pkg-test/src/fs-extra.js: -------------------------------------------------------------------------------- 1 | const fse = require('fs-extra'); 2 | 3 | fse.copySync('./src', './aaa/bbb/') 4 | -------------------------------------------------------------------------------- /scan-thread-pool/README.md: -------------------------------------------------------------------------------- 1 | # scan thread pool 2 | 3 | npm install 4 | 5 | npx tsc -w 6 | 7 | node ./dist/index.js -------------------------------------------------------------------------------- /excel-export/bundle.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkGluonPlasma/nodejs-course-code/HEAD/excel-export/bundle.xlsx -------------------------------------------------------------------------------- /keyboard-control/src/test.ts: -------------------------------------------------------------------------------- 1 | const arr = []; 2 | 3 | setInterval(() => { 4 | arr.push(Math.random()); 5 | }, 10) 6 | -------------------------------------------------------------------------------- /my-create-vite/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkGluonPlasma/nodejs-course-code/HEAD/my-create-vite/.DS_Store -------------------------------------------------------------------------------- /cli-progress-test/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkGluonPlasma/nodejs-course-code/HEAD/cli-progress-test/.DS_Store -------------------------------------------------------------------------------- /cli-dashboard/README.md: -------------------------------------------------------------------------------- 1 | # cli-dashboard 2 | 3 | cli 系统监控仪表盘 4 | 5 | npm install 6 | 7 | npx tsc -w 8 | 9 | node ./dist/index.js -------------------------------------------------------------------------------- /pnpm-monorepo-test/packages/core/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @guang-pnpm/core 2 | 3 | ## 1.1.0 4 | 5 | ### Minor Changes 6 | 7 | - 数字加减 cli 8 | -------------------------------------------------------------------------------- /keyboard-control/README.md: -------------------------------------------------------------------------------- 1 | # keyboard control 2 | 3 | 键盘控制 cli 4 | 5 | npm install 6 | 7 | npx tsc 8 | 9 | node ./dist/list-test.js -------------------------------------------------------------------------------- /my-prompts/README.md: -------------------------------------------------------------------------------- 1 | # my prompts 2 | 3 | 实现 prompts 4 | 5 | npm install 6 | 7 | npx tsc -w 8 | 9 | node ./dist/test2.js 10 | -------------------------------------------------------------------------------- /cli-args-test/index.js: -------------------------------------------------------------------------------- 1 | const minimist = require('minimist'); 2 | 3 | const argv = minimist(process.argv.slice(2)); 4 | console.log(argv); 5 | -------------------------------------------------------------------------------- /my-create-vite/template-vue/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkGluonPlasma/nodejs-course-code/HEAD/my-create-vite/template-vue/.DS_Store -------------------------------------------------------------------------------- /rollup-test/README.md: -------------------------------------------------------------------------------- 1 | # rollup-test 2 | 3 | npm install 4 | 5 | npx rollup -c rollup.config.mjs 6 | 7 | npx webpack-cli -c webpack.config.mjs 8 | -------------------------------------------------------------------------------- /cli-progress-test/README.md: -------------------------------------------------------------------------------- 1 | # cli-progress-test 2 | 3 | 实现 cli 进度条 4 | 5 | npm install 6 | 7 | npx tsc 8 | 9 | node ./dist/index.js 10 | -------------------------------------------------------------------------------- /exceljs-test/README.md: -------------------------------------------------------------------------------- 1 | # excel 的解析和生成 2 | 3 | npm install 4 | 5 | node ./index.js 6 | 7 | node ./index2.js 8 | 9 | npx http-server . 10 | -------------------------------------------------------------------------------- /my-create-vite/template-react/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkGluonPlasma/nodejs-course-code/HEAD/my-create-vite/template-react/.DS_Store -------------------------------------------------------------------------------- /my-create-vite/template-vue-ts/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkGluonPlasma/nodejs-course-code/HEAD/my-create-vite/template-vue-ts/.DS_Store -------------------------------------------------------------------------------- /my-nest-cli/nest-project/aaa.module.ts: -------------------------------------------------------------------------------- 1 | //@ts-ignore 2 | import { Module } from "@nestjs/common"; 3 | 4 | @Module({}) 5 | export class AaaModule {} 6 | -------------------------------------------------------------------------------- /guang-cli/packages/template-react/questions.json: -------------------------------------------------------------------------------- 1 | { 2 | "eslint": { 3 | "files": [ 4 | "eslint.config.js" 5 | ] 6 | } 7 | } -------------------------------------------------------------------------------- /my-create-vite/template-react-ts/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuarkGluonPlasma/nodejs-course-code/HEAD/my-create-vite/template-react-ts/.DS_Store -------------------------------------------------------------------------------- /my-source-map-support/README.md: -------------------------------------------------------------------------------- 1 | # my-source-map-support 2 | 3 | npm install 4 | 5 | npx tsc -w 6 | 7 | node --import ./dist/register.js ./dist/index.js -------------------------------------------------------------------------------- /rollup-test/src/utils.js: -------------------------------------------------------------------------------- 1 | import './utils.css'; 2 | 3 | function add(a, b) { 4 | return a + b; 5 | } 6 | 7 | export { 8 | add 9 | } 10 | -------------------------------------------------------------------------------- /guang-cli/packages/generate/src/configType.ts: -------------------------------------------------------------------------------- 1 | export interface ConfigOptions { 2 | apiKey: string; 3 | baseUrl: string; 4 | systemSetting: string; 5 | } -------------------------------------------------------------------------------- /stream-test/src/read.mjs: -------------------------------------------------------------------------------- 1 | process.stdin.on('readable', function () { 2 | const buf = process.stdin.read(); 3 | console.log(buf?.toString('utf-8')); 4 | }); 5 | -------------------------------------------------------------------------------- /my-create-vite/template-vue-ts/src/main.ts: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import './style.css' 3 | import App from './App.vue' 4 | 5 | createApp(App).mount('#app') 6 | -------------------------------------------------------------------------------- /my-create-vite/template-vue/src/main.js: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import './style.css' 3 | import App from './App.vue' 4 | 5 | createApp(App).mount('#app') 6 | -------------------------------------------------------------------------------- /react-comp/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | { "path": "./tsconfig.app.json" }, 5 | { "path": "./tsconfig.node.json" } 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /my-comp-lib-test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | { "path": "./tsconfig.app.json" }, 5 | { "path": "./tsconfig.node.json" } 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /react-comp-lib/src/index.ts: -------------------------------------------------------------------------------- 1 | import Button, { ButtonProps } from './Button'; 2 | 3 | export { 4 | Button 5 | } 6 | 7 | export type { 8 | ButtonProps 9 | } 10 | -------------------------------------------------------------------------------- /react-i18n-test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | { "path": "./tsconfig.app.json" }, 5 | { "path": "./tsconfig.node.json" } 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /guang-cli/packages/template-vue/template/src/main.ts: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import './style.css' 3 | import App from './App.vue' 4 | 5 | createApp(App).mount('#app') 6 | -------------------------------------------------------------------------------- /rollup-test/src/index.js: -------------------------------------------------------------------------------- 1 | import { add } from './utils'; 2 | import './index.css'; 3 | 4 | function main() { 5 | console.log(add(1, 2)) 6 | } 7 | 8 | export default main; 9 | -------------------------------------------------------------------------------- /my-create-vite/template-react-ts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | { "path": "./tsconfig.app.json" }, 5 | { "path": "./tsconfig.node.json" } 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /my-create-vite/template-vue-ts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | { "path": "./tsconfig.app.json" }, 5 | { "path": "./tsconfig.node.json" } 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /node-api-test/cp3.mjs: -------------------------------------------------------------------------------- 1 | import cp from 'node:child_process'; 2 | 3 | const child = cp.execFile('/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome', ['--user-data-dir=./aaa']); 4 | -------------------------------------------------------------------------------- /node-api-test/v8.mjs: -------------------------------------------------------------------------------- 1 | import v8 from 'node:v8'; 2 | 3 | console.log(v8.getHeapSpaceStatistics()); 4 | 5 | console.log(v8.getHeapStatistics()); 6 | 7 | v8.setFlagsFromString('--trace_gc'); 8 | -------------------------------------------------------------------------------- /guang-cli/packages/template-react/template/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | { "path": "./tsconfig.app.json" }, 5 | { "path": "./tsconfig.node.json" } 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /guang-cli/packages/template-vue/template/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | { "path": "./tsconfig.app.json" }, 5 | { "path": "./tsconfig.node.json" } 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /guang-cli/packages/utils/src/index.ts: -------------------------------------------------------------------------------- 1 | import NpmPackage from "./NpmPackage.js"; 2 | import * as versionUtils from './versionUtils.js'; 3 | 4 | export { 5 | NpmPackage, 6 | versionUtils 7 | } 8 | -------------------------------------------------------------------------------- /node-api-test/dns.mjs: -------------------------------------------------------------------------------- 1 | import dns from 'node:dns/promises'; 2 | 3 | async function main() { 4 | const res = await dns.resolve('baidu.com'); 5 | console.log(res); 6 | } 7 | 8 | main(); 9 | 10 | -------------------------------------------------------------------------------- /node-api-test/cluster2.mjs: -------------------------------------------------------------------------------- 1 | import http from 'node:http'; 2 | 3 | const server = http.createServer((req, res) => { 4 | res.writeHead(200); 5 | res.end('hello guang\n'); 6 | }) 7 | 8 | server.listen(8000); 9 | -------------------------------------------------------------------------------- /react-comp/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | 4 | // https://vite.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | }) 8 | -------------------------------------------------------------------------------- /my-comp-lib-test/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | 4 | // https://vite.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | }) 8 | -------------------------------------------------------------------------------- /react-i18n-test/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | }) 8 | -------------------------------------------------------------------------------- /buffer-test/index3.js: -------------------------------------------------------------------------------- 1 | const fs = require('node:fs/promises'); 2 | 3 | (async function(){ 4 | const res = await fs.readFile('./package.json', { 5 | encoding: 'utf-8' 6 | }); 7 | console.log(res); 8 | })(); -------------------------------------------------------------------------------- /guang-cli/packages/generate/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @guang-cli/generate 2 | 3 | ## 1.2.0 4 | 5 | ### Minor Changes 6 | 7 | - generate command 8 | 9 | ## 1.1.0 10 | 11 | ### Minor Changes 12 | 13 | - generate + config 14 | -------------------------------------------------------------------------------- /my-create-vite/template-vue/vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import vue from '@vitejs/plugin-vue' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [vue()], 7 | }) 8 | -------------------------------------------------------------------------------- /excel-export/zh-CN.json: -------------------------------------------------------------------------------- 1 | { 2 | "username": "用户名 {name}", 3 | "password": "密码222", 4 | "rememberMe": "记住我333", 5 | "submit": "提交", 6 | "inputYourUsername": "请输入你的用户名!", 7 | "inputYourPassword": "请输入你的密码!" 8 | } -------------------------------------------------------------------------------- /my-create-vite/template-vue-ts/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import vue from '@vitejs/plugin-vue' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [vue()], 7 | }) 8 | -------------------------------------------------------------------------------- /sqlite-test/src/index2.mjs: -------------------------------------------------------------------------------- 1 | import { DatabaseSync } from 'node:sqlite'; 2 | const database = new DatabaseSync('data.db'); 3 | 4 | const query = database.prepare('SELECT * FROM student ORDER BY id'); 5 | console.log(query.all()); 6 | -------------------------------------------------------------------------------- /guang-cli/packages/template-vue/template/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import vue from '@vitejs/plugin-vue' 3 | 4 | // https://vite.dev/config/ 5 | export default defineConfig({ 6 | plugins: [vue()], 7 | }) 8 | -------------------------------------------------------------------------------- /my-create-vite/template-react-ts/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | }) 8 | -------------------------------------------------------------------------------- /my-create-vite/template-react/vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | }) 8 | -------------------------------------------------------------------------------- /pnpm-monorepo-test/packages/cli/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @guang-pnpm/cli 2 | 3 | ## 1.1.0 4 | 5 | ### Minor Changes 6 | 7 | - 数字加减 cli 8 | 9 | ### Patch Changes 10 | 11 | - Updated dependencies 12 | - @guang-pnpm/core@1.1.0 13 | -------------------------------------------------------------------------------- /buffer-test/index5.js: -------------------------------------------------------------------------------- 1 | const { Buffer } = require('node:buffer'); 2 | 3 | const buffer = Buffer.alloc(10); 4 | 5 | buffer.writeUint16LE(256, 0) 6 | 7 | console.log(buffer.readUInt16LE(0)); 8 | console.log(buffer.readUint8(0), buffer.readUint8(1)); -------------------------------------------------------------------------------- /guang-cli/packages/template-react/template/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | 4 | // https://vite.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | }) 8 | -------------------------------------------------------------------------------- /node-api-test/buffer2.mjs: -------------------------------------------------------------------------------- 1 | import { Buffer } from 'node:buffer'; 2 | 3 | const buffer = Buffer.alloc(10); 4 | 5 | buffer.writeUint16LE(256, 0) 6 | 7 | console.log(buffer.readUInt16LE(0)); 8 | console.log(buffer.readUint8(0), buffer.readUint8(1)); -------------------------------------------------------------------------------- /node-api-test/fs.mjs: -------------------------------------------------------------------------------- 1 | import fs from 'node:fs'; 2 | 3 | fs.mkdirSync('aaa'); 4 | 5 | setTimeout(() => { 6 | fs.renameSync('aaa', 'bbb'); 7 | }, 1000); 8 | 9 | setTimeout(() => { 10 | fs.rmdirSync('bbb'); 11 | }, 3000); 12 | 13 | -------------------------------------------------------------------------------- /node-api-test/vm.mjs: -------------------------------------------------------------------------------- 1 | import vm from 'node:vm'; 2 | 3 | const context = { 4 | console, 5 | guang: 111, 6 | dong: 222 7 | } 8 | 9 | vm.createContext(context); 10 | 11 | vm.runInContext('console.log(guang + dong)', context); 12 | -------------------------------------------------------------------------------- /pnpm-monorepo-test/packages/core/src/index.ts: -------------------------------------------------------------------------------- 1 | function add(a: number, b: number) { 2 | return a + b; 3 | } 4 | 5 | function minus(a: number, b: number) { 6 | return a - b; 7 | } 8 | 9 | export { 10 | add, 11 | minus 12 | } 13 | -------------------------------------------------------------------------------- /guang-cli/packages/utils/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @guang-cli/utils 2 | 3 | ## 1.1.2 4 | 5 | ### Patch Changes 6 | 7 | - utils 8 | 9 | ## 1.1.1 10 | 11 | ### Patch Changes 12 | 13 | - utils 14 | 15 | ## 1.1.0 16 | 17 | ### Minor Changes 18 | 19 | - utils 包 20 | -------------------------------------------------------------------------------- /my-nest-cli/README.md: -------------------------------------------------------------------------------- 1 | # my nest cli 2 | 3 | 掘金小册 《Node.js 工具链通关秘籍》案例代码 4 | 5 | 第一步,全局安装这个命令: 6 | 7 | ``` 8 | npm install -g my-nest-cli 9 | ``` 10 | 11 | 第二步,进入 Nest 项目目录,执行 my-cli transform 12 | 13 | ``` 14 | my-cli transform ./src/app.module.ts 15 | ``` -------------------------------------------------------------------------------- /node-api-test/crypto.mjs: -------------------------------------------------------------------------------- 1 | import crypto from 'node:crypto'; 2 | 3 | export function md5(str) { 4 | const hash = crypto.createHash('md5'); 5 | hash.update(str); 6 | return hash.digest('hex'); 7 | } 8 | 9 | console.log(md5('123456')); 10 | 11 | -------------------------------------------------------------------------------- /my-source-map-support/src/index.ts: -------------------------------------------------------------------------------- 1 | function add(a: number, b: number) { 2 | if(a === 1) { 3 | throw new Error('xxx2'); 4 | } 5 | return a + b; 6 | } 7 | 8 | function main() { 9 | console.log(add(1,2)); 10 | } 11 | 12 | main(); 13 | 14 | -------------------------------------------------------------------------------- /node-api-test/string_decoder.mjs: -------------------------------------------------------------------------------- 1 | import { StringDecoder } from 'node:string_decoder'; 2 | import { Buffer } from 'node:buffer'; 3 | 4 | const decoder = new StringDecoder('utf8'); 5 | 6 | const buf = Buffer.from('神说要有光', 'utf-8'); 7 | console.log(decoder.write(buf)); 8 | 9 | -------------------------------------------------------------------------------- /worker-test/page/worker.js: -------------------------------------------------------------------------------- 1 | function calc(num) { 2 | let total = 0; 3 | for(let i = 0; i< num; i++) { 4 | total += i; 5 | } 6 | return total 7 | } 8 | 9 | addEventListener('message', function(evt) { 10 | postMessage(calc(evt.data)); 11 | }); -------------------------------------------------------------------------------- /excel-export/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "username": "Username {name}", 3 | "password": "Password", 4 | "rememberMe": "Remember Me", 5 | "submit": "Submit", 6 | "inputYourUsername": "Please input your username!", 7 | "inputYourPassword": "Please input your password!" 8 | } -------------------------------------------------------------------------------- /node-api-test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | hello 10 | 11 | -------------------------------------------------------------------------------- /node-api-test/meta2.mjs: -------------------------------------------------------------------------------- 1 | import url from 'node:url'; 2 | 3 | console.log(import.meta.url); 4 | console.log(import.meta.resolve('./a.js')) 5 | 6 | console.log(import.meta.dirname); 7 | console.log(import.meta.filename); 8 | 9 | console.log(url.fileURLToPath(import.meta.url)) 10 | -------------------------------------------------------------------------------- /node-api-test/query_string.mjs: -------------------------------------------------------------------------------- 1 | import queryString from 'node:querystring'; 2 | 3 | const res = queryString.parse('a=1&b=2&c=xxx'); 4 | 5 | console.log(res); 6 | 7 | const res2 = queryString.stringify({ aaa: '111', bbb: ['222', '33'], ccc: '444' }); 8 | 9 | console.log(res2); 10 | -------------------------------------------------------------------------------- /scaffold-pkg-test/src/cli-spinner.js: -------------------------------------------------------------------------------- 1 | const Spinner = require('cli-spinner').Spinner 2 | 3 | console.log('111'); 4 | console.log('222'); 5 | 6 | const spinner = new Spinner(`安装中.. %s`) 7 | spinner.start() 8 | 9 | setTimeout(() => { 10 | spinner.stop(true); 11 | }, 3000); 12 | -------------------------------------------------------------------------------- /node-api-test/util3.mjs: -------------------------------------------------------------------------------- 1 | import util from 'util'; 2 | 3 | const flag = util.debug('flag'); 4 | 5 | if (flag.enabled) { 6 | console.log('这是一条 debug 日志 111'); 7 | } 8 | 9 | const flag2 = util.debug('flag2'); 10 | 11 | if (flag2.enabled) { 12 | console.log('这是一条 debug 日志 222'); 13 | } 14 | -------------------------------------------------------------------------------- /react-comp/src/App.tsx: -------------------------------------------------------------------------------- 1 | import Button from "./Button" 2 | 3 | function App() { 4 | 5 | return
6 | 7 | 8 |
9 | } 10 | 11 | export default App 12 | -------------------------------------------------------------------------------- /react-comp/src/main.tsx: -------------------------------------------------------------------------------- 1 | import { StrictMode } from 'react' 2 | import { createRoot } from 'react-dom/client' 3 | // import './index.css' 4 | import App from './App.tsx' 5 | 6 | createRoot(document.getElementById('root')!).render( 7 | 8 | 9 | , 10 | ) 11 | -------------------------------------------------------------------------------- /scaffold-pkg-test/src/glob.js: -------------------------------------------------------------------------------- 1 | const { glob } = require('glob'); 2 | 3 | async function main() { 4 | const files = await glob('**', { 5 | cwd: process.cwd(), 6 | nodir: true, 7 | ignore: 'node_modules/**' 8 | }) 9 | console.log(files); 10 | } 11 | 12 | main(); -------------------------------------------------------------------------------- /buffer-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "buffer-test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC" 12 | } 13 | -------------------------------------------------------------------------------- /excel-export/messages.csv: -------------------------------------------------------------------------------- 1 | Message ID,zh-CN,en-US 2 | username,用户名 {name},Username {name} 3 | password,密码222,Password 4 | rememberMe,记住我,Remember Me 5 | submit,提交,Submit 6 | inputYourUsername,请输入你的用户名!,Please input your username! 7 | inputYourPassword,请输入你的密码!,Please input your password! 8 | -------------------------------------------------------------------------------- /my-comp-lib-test/src/main.tsx: -------------------------------------------------------------------------------- 1 | import { StrictMode } from 'react' 2 | import { createRoot } from 'react-dom/client' 3 | // import './index.css' 4 | import App from './App.tsx' 5 | 6 | createRoot(document.getElementById('root')!).render( 7 | 8 | 9 | , 10 | ) 11 | -------------------------------------------------------------------------------- /my-websocket/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-websocket", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC" 12 | } 13 | -------------------------------------------------------------------------------- /worker-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "worker-test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC" 12 | } 13 | -------------------------------------------------------------------------------- /ansi-test/index2.js: -------------------------------------------------------------------------------- 1 | import readline from 'node:readline'; 2 | 3 | const repeatCount = process.stdout.rows - 2; 4 | const blank = repeatCount > 0 ? '\n'.repeat(repeatCount) : ''; 5 | console.log(blank); 6 | 7 | readline.cursorTo(process.stdout, 0, 0); 8 | readline.clearScreenDown(process.stdout); 9 | 10 | -------------------------------------------------------------------------------- /excel-export/message2.csv: -------------------------------------------------------------------------------- 1 | Message ID,zh-CN,en-US 2 | username,用户名 {name},Username {name} 3 | password,密码222,Password 4 | rememberMe,记住我333,Remember Me 5 | submit,提交,Submit 6 | inputYourUsername,请输入你的用户名!,Please input your username! 7 | inputYourPassword,请输入你的密码!,Please input your password! -------------------------------------------------------------------------------- /my-dns-server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-dns-server", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC" 12 | } 13 | -------------------------------------------------------------------------------- /node-api-test/crypto3.mjs: -------------------------------------------------------------------------------- 1 | import crypto from 'node:crypto'; 2 | 3 | console.log(crypto.randomInt(10)); 4 | console.log(crypto.randomInt(10)); 5 | console.log(crypto.randomInt(10)); 6 | console.log(crypto.randomInt(10)); 7 | 8 | console.log(crypto.randomUUID()); 9 | console.log(crypto.randomUUID()); 10 | -------------------------------------------------------------------------------- /node-api-test/readline.mjs: -------------------------------------------------------------------------------- 1 | import { createReadStream } from 'node:fs'; 2 | import { createInterface } from 'node:readline'; 3 | 4 | const rl = createInterface({ 5 | input: createReadStream('./repl.mjs') 6 | }); 7 | 8 | rl.on('line', (line) => { 9 | console.log(`Line from file: ${line}`); 10 | }); 11 | -------------------------------------------------------------------------------- /buffer-test/index2.js: -------------------------------------------------------------------------------- 1 | const buffer = new ArrayBuffer(10); 2 | 3 | const dataView = new DataView(buffer); 4 | 5 | dataView.setUint16(0, 256); 6 | 7 | console.log(dataView.getUint16(0)); 8 | 9 | console.log(dataView.getUint8(0)); 10 | console.log(dataView.getUint8(8)); -------------------------------------------------------------------------------- /my-create-vite/template-react/src/main.jsx: -------------------------------------------------------------------------------- 1 | import { StrictMode } from 'react' 2 | import { createRoot } from 'react-dom/client' 3 | import App from './App.jsx' 4 | import './index.css' 5 | 6 | createRoot(document.getElementById('root')).render( 7 | 8 | 9 | , 10 | ) 11 | -------------------------------------------------------------------------------- /node-api-test/fs2.mjs: -------------------------------------------------------------------------------- 1 | import fs from 'node:fs'; 2 | import { EOL } from 'node:os'; 3 | 4 | fs.writeFileSync('aaa.txt', 'hello' + EOL); 5 | 6 | setTimeout(() => { 7 | fs.appendFileSync('aaa.txt', 'world' + EOL) 8 | }, 2000); 9 | 10 | setTimeout(() => { 11 | fs.unlinkSync('aaa.txt'); 12 | }, 4000) 13 | -------------------------------------------------------------------------------- /node-api-test/path.mjs: -------------------------------------------------------------------------------- 1 | import path from 'node:path'; 2 | import { fileURLToPath } from 'node:url' 3 | 4 | const filePath = fileURLToPath(import.meta.url) 5 | 6 | console.log(filePath) 7 | console.log(path.dirname(filePath)); 8 | console.log(path.basename(filePath)); 9 | console.log(path.extname(filePath)); 10 | -------------------------------------------------------------------------------- /my-create-vite/template-react-ts/src/main.tsx: -------------------------------------------------------------------------------- 1 | import { StrictMode } from 'react' 2 | import { createRoot } from 'react-dom/client' 3 | import App from './App.tsx' 4 | import './index.css' 5 | 6 | createRoot(document.getElementById('root')!).render( 7 | 8 | 9 | , 10 | ) 11 | -------------------------------------------------------------------------------- /my-nest-cli/src/test.ts: -------------------------------------------------------------------------------- 1 | import path from "node:path"; 2 | import { transformFile } from "./transform.js"; 3 | 4 | (async function() { 5 | const filePath = path.join(process.cwd(), './nest-project/aaa.module.ts'); 6 | 7 | const code = await transformFile(filePath); 8 | console.log(code); 9 | })(); 10 | -------------------------------------------------------------------------------- /node-api-test/util.mjs: -------------------------------------------------------------------------------- 1 | import util from 'node:util'; 2 | 3 | console.log(util.format 4 | `这是一个数字:%d 5 | 这是一个字符串:%s 6 | 这是一个 JSON:%j 7 | 这是一个 对象:%o`, 111, '神说要有光', { 8 | a: 1, 9 | b: { 10 | c: 2 11 | } 12 | }, { 13 | a: 1, 14 | b: { 15 | c: 2 16 | } 17 | }); 18 | 19 | 20 | -------------------------------------------------------------------------------- /stream-test/src/fsReadStream.mjs: -------------------------------------------------------------------------------- 1 | import fs from 'node:fs'; 2 | 3 | const readStream = fs.createReadStream(import.meta.dirname + '/data.txt', 'utf-8'); 4 | 5 | readStream.on('data', (data)=> { 6 | console.log(data.toString()) 7 | }); 8 | 9 | readStream.on('end', () => { 10 | console.log('done'); 11 | }); 12 | -------------------------------------------------------------------------------- /guang-cli/packages/template-react/template/src/main.tsx: -------------------------------------------------------------------------------- 1 | import { StrictMode } from 'react' 2 | import { createRoot } from 'react-dom/client' 3 | import './index.css' 4 | import App from './App.tsx' 5 | 6 | createRoot(document.getElementById('root')!).render( 7 | 8 | 9 | , 10 | ) 11 | -------------------------------------------------------------------------------- /node-api-test/os.mjs: -------------------------------------------------------------------------------- 1 | import os from 'node:os'; 2 | 3 | console.log('aaa' + os.EOL + 'bbb' + os.EOL); 4 | 5 | console.log(os.cpus()); 6 | 7 | console.log(os.type()); 8 | console.log(os.userInfo()) 9 | console.log(os.freemem(), os.totalmem()); 10 | 11 | console.log(os.homedir()); 12 | console.log(os.networkInterfaces()) 13 | -------------------------------------------------------------------------------- /scaffold-pkg-test/src/ora.js: -------------------------------------------------------------------------------- 1 | const ora = require('ora'); 2 | 3 | console.log(111); 4 | console.log(222); 5 | 6 | const spinner = ora('下载中...').start(); 7 | 8 | setTimeout(() => { 9 | spinner.color = 'yellow'; 10 | spinner.text = '快了快了...'; 11 | }, 2000); 12 | 13 | setTimeout(() => { 14 | spinner.stop(); 15 | }, 5000); -------------------------------------------------------------------------------- /stream-test/src/test2.mjs: -------------------------------------------------------------------------------- 1 | import http from 'node:http'; 2 | import fs from 'node:fs'; 3 | 4 | const server = http.createServer(async function (req, res) { 5 | const writeStream = fs.createWriteStream('aaa.txt', 'utf-8'); 6 | req.pipe(writeStream); 7 | res.end('done'); 8 | }); 9 | 10 | server.listen(8000); 11 | -------------------------------------------------------------------------------- /node-api-test/fs3.mjs: -------------------------------------------------------------------------------- 1 | import fs from 'node:fs'; 2 | 3 | fs.mkdirSync('aaa/bbb/ccc/ddd', { 4 | recursive: true 5 | }); 6 | 7 | fs.writeFileSync('aaa/a.txt', '111'); 8 | fs.writeFileSync('aaa/bbb/b.txt', '222'); 9 | fs.writeFileSync('aaa/bbb/ccc/c.txt', '333'); 10 | fs.writeFileSync('aaa/bbb/ccc/ddd/d.txt', '444'); 11 | 12 | -------------------------------------------------------------------------------- /cli-args-test/index2.js: -------------------------------------------------------------------------------- 1 | const minimist = require('minimist'); 2 | 3 | const argv = minimist(process.argv.slice(2), { 4 | boolean: ['x'], 5 | string: ['y'], 6 | unknown(arg) { 7 | return arg === '-u' 8 | }, 9 | default: { y: 2333 }, 10 | alias: { p: 'port', t: 'template' } 11 | }); 12 | console.log(argv); 13 | -------------------------------------------------------------------------------- /node-api-test/readline3.mjs: -------------------------------------------------------------------------------- 1 | import readline from 'node:readline'; 2 | 3 | readline.emitKeypressEvents(process.stdin); 4 | 5 | process.stdin.setRawMode(true); 6 | 7 | process.stdin.on('keypress', (str, key) => { 8 | 9 | console.log(str, key) 10 | 11 | if(key.sequence === '\u0003') { 12 | process.exit(); 13 | } 14 | }); -------------------------------------------------------------------------------- /node-api-test/repl.mjs: -------------------------------------------------------------------------------- 1 | import repl from 'node:repl'; 2 | import cfonts from 'cfonts'; 3 | 4 | const r = repl.start({ prompt: '> ', eval: myEval}); 5 | 6 | function myEval(cmd, context, filename, callback) { 7 | cfonts.say(cmd, { 8 | font: '3D', 9 | colors: ['yellow', 'cyan'] 10 | }); 11 | callback(); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /guang-cli/.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@3.0.3/schema.json", 3 | "changelog": "@changesets/cli/changelog", 4 | "commit": false, 5 | "fixed": [], 6 | "linked": [], 7 | "access": "restricted", 8 | "baseBranch": "main", 9 | "updateInternalDependencies": "patch", 10 | "ignore": [] 11 | } 12 | -------------------------------------------------------------------------------- /keyboard-control/src/index.ts: -------------------------------------------------------------------------------- 1 | import readline from 'node:readline'; 2 | 3 | readline.emitKeypressEvents(process.stdin); 4 | 5 | 6 | process.stdin.setRawMode(true); 7 | 8 | process.stdin.on('keypress', (str, key) => { 9 | 10 | if(key.sequence === '\u0003') { 11 | process.exit(); 12 | } 13 | 14 | console.log(str, key) 15 | }); -------------------------------------------------------------------------------- /node-api-test/crypto2.mjs: -------------------------------------------------------------------------------- 1 | import { createHash } from 'node:crypto'; 2 | import { Readable } from 'node:stream'; 3 | 4 | const rs = new Readable(); 5 | rs._read = function() { 6 | this.push('123456'); 7 | this.push(null); 8 | } 9 | 10 | const hash = createHash('sha256'); 11 | rs.pipe(hash).setEncoding('hex').pipe(process.stdout); 12 | 13 | -------------------------------------------------------------------------------- /my-prompts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "types": [ "node" ], 5 | "target": "es2016", 6 | "module": "NodeNext", 7 | "moduleResolution": "NodeNext", 8 | "esModuleInterop": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "strict": true, 11 | "skipLibCheck": true, 12 | } 13 | } -------------------------------------------------------------------------------- /node-api-test/cp2.mjs: -------------------------------------------------------------------------------- 1 | import cp from "node:child_process"; 2 | 3 | const ls = cp.exec('ls -l'); 4 | 5 | ls.stdout.on('data', (data) => { 6 | console.log(`stdout: ${data}`); 7 | }); 8 | 9 | ls.stderr.on('data', (data) => { 10 | console.error(`stderr: ${data}`); 11 | }); 12 | 13 | ls.on('close', (code) => { 14 | console.log(`进程退出 ${code}`); 15 | }); 16 | -------------------------------------------------------------------------------- /pnpm-monorepo-test/.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@3.0.3/schema.json", 3 | "changelog": "@changesets/cli/changelog", 4 | "commit": false, 5 | "fixed": [], 6 | "linked": [], 7 | "access": "restricted", 8 | "baseBranch": "main", 9 | "updateInternalDependencies": "patch", 10 | "ignore": [] 11 | } 12 | -------------------------------------------------------------------------------- /auto-i18n-cli/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "types": [ "node" ], 5 | "target": "es2016", 6 | "module": "NodeNext", 7 | "moduleResolution": "NodeNext", 8 | "esModuleInterop": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "strict": true, 11 | "skipLibCheck": true, 12 | } 13 | } -------------------------------------------------------------------------------- /blessed-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "blessed-test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "blessed": "^0.1.81" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /cli-dashboard/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "types": [ "node" ], 5 | "target": "es2016", 6 | "module": "NodeNext", 7 | "moduleResolution": "NodeNext", 8 | "esModuleInterop": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "strict": true, 11 | "skipLibCheck": true, 12 | } 13 | } -------------------------------------------------------------------------------- /exceljs-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "exceljs-test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "exceljs": "^4.4.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /keyboard-control/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "types": [ "node" ], 5 | "target": "es2016", 6 | "module": "NodeNext", 7 | "moduleResolution": "NodeNext", 8 | "esModuleInterop": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "strict": true, 11 | "skipLibCheck": true, 12 | } 13 | } -------------------------------------------------------------------------------- /openai-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openai-test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "openai": "^4.73.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /scaffold-pkg-test/src/npminstall.js: -------------------------------------------------------------------------------- 1 | const npminstall = require('npminstall'); 2 | 3 | (async () => { 4 | await npminstall({ 5 | pkgs: [ 6 | { name: 'chalk', version: 'latest' }, 7 | ], 8 | root: process.cwd() + '/aaa', 9 | registry: 'https://registry.npmjs.org', 10 | }); 11 | })().catch(err => { 12 | console.error(err); 13 | }); 14 | -------------------------------------------------------------------------------- /scan-thread-pool/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "types": [ "node" ], 5 | "target": "es2016", 6 | "module": "NodeNext", 7 | "moduleResolution": "NodeNext", 8 | "esModuleInterop": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "strict": true, 11 | "skipLibCheck": true, 12 | } 13 | } -------------------------------------------------------------------------------- /ast-transform-test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "types": [ "node" ], 5 | "target": "es2016", 6 | "module": "NodeNext", 7 | "moduleResolution": "NodeNext", 8 | "esModuleInterop": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "strict": true, 11 | "skipLibCheck": true, 12 | } 13 | } -------------------------------------------------------------------------------- /buffer-test/index6.js: -------------------------------------------------------------------------------- 1 | const { Blob } = require('node:buffer'); 2 | 3 | const blob = new Blob(['神说要有光']); 4 | 5 | const { port1, port2 } = new MessageChannel(); 6 | 7 | port1.onmessage = async ({ data }) => { 8 | console.log(data); 9 | console.log(await data.text()) 10 | console.log(await data.arrayBuffer()) 11 | }; 12 | 13 | port2.postMessage(blob); 14 | 15 | -------------------------------------------------------------------------------- /my-source-map-support/test.js: -------------------------------------------------------------------------------- 1 | import { SourceMapConsumer } from 'source-map'; 2 | import fs from 'node:fs'; 3 | 4 | const mapContent = fs.readFileSync('./dist/index.js.map', 'utf-8'); 5 | 6 | const map = new SourceMapConsumer(mapContent); 7 | 8 | const position = map.originalPositionFor({ 9 | line: 54, 10 | column: 0 11 | }); 12 | 13 | console.log(position); -------------------------------------------------------------------------------- /node-api-test/http-server.mjs: -------------------------------------------------------------------------------- 1 | import http from 'node:http'; 2 | import fs from 'node:fs'; 3 | 4 | const server = http.createServer(async function (req, res) { 5 | 6 | const writeStream = fs.createWriteStream('aaa.txt', 'utf-8'); 7 | req.pipe(writeStream); 8 | 9 | res.write('66666'); 10 | res.end('done'); 11 | }); 12 | 13 | server.listen(8000); 14 | -------------------------------------------------------------------------------- /stream-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "stream-test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "@types/node": "^22.10.2" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /cli-progress-test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "types": [ "node" ], 5 | "target": "es2016", 6 | "module": "NodeNext", 7 | "moduleResolution": "NodeNext", 8 | "esModuleInterop": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "strict": true, 11 | "skipLibCheck": true, 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /guang-cli/packages/generate/src/test.ts: -------------------------------------------------------------------------------- 1 | import { cosmiconfig, cosmiconfigSync } from 'cosmiconfig'; 2 | import path from 'node:path'; 3 | 4 | const explorer = cosmiconfig("xxx"); 5 | 6 | async function main() { 7 | const result = await explorer.search(path.join(import.meta.dirname, '../')); 8 | 9 | console.log(result?.config); 10 | 11 | } 12 | 13 | main(); 14 | -------------------------------------------------------------------------------- /guang-cli/packages/template-vue/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @guang-cli/template-vue 2 | 3 | ## 1.2.2 4 | 5 | ### Patch Changes 6 | 7 | - generate command 8 | 9 | ## 1.2.1 10 | 11 | ### Patch Changes 12 | 13 | - generate + config 14 | 15 | ## 1.2.0 16 | 17 | ### Minor Changes 18 | 19 | - ejs template 20 | 21 | ## 1.1.0 22 | 23 | ### Minor Changes 24 | 25 | - guang-cli 项目模版 26 | -------------------------------------------------------------------------------- /mini-puppeteer/src/lib/helpers.mjs: -------------------------------------------------------------------------------- 1 | function evaluate(client, fun, args) { 2 | var argsString = args.map(x => JSON.stringify(x)).join(','); 3 | var code = `(${fun.toString()})(${argsString})`; 4 | 5 | return client.send('Runtime.evaluate', { 6 | expression: code, 7 | returnByValue: true 8 | }); 9 | } 10 | 11 | export { 12 | evaluate 13 | } -------------------------------------------------------------------------------- /node-api-test/cp1.mjs: -------------------------------------------------------------------------------- 1 | import cp from "node:child_process"; 2 | 3 | const ls = cp.spawn('ls', ['-l', './']); 4 | 5 | ls.stdout.on('data', (data) => { 6 | console.log(`stdout: ${data}`); 7 | }); 8 | 9 | ls.stderr.on('data', (data) => { 10 | console.error(`stderr: ${data}`); 11 | }); 12 | 13 | ls.on('close', (code) => { 14 | console.log(`进程退出 ${code}`); 15 | }); 16 | -------------------------------------------------------------------------------- /stream-test/src/fsWriteStream.mjs: -------------------------------------------------------------------------------- 1 | import fs from 'node:fs'; 2 | 3 | const writeStream = fs.createWriteStream('tmp.txt', 'utf-8'); 4 | 5 | writeStream.on('finish', () => console.log('done')); 6 | 7 | writeStream.write('阿门阿前一棵葡萄树,'); 8 | writeStream.write('阿东阿东绿的刚发芽,'); 9 | writeStream.write('阿东背着那重重的的壳呀,'); 10 | writeStream.write('一步一步地往上爬。'); 11 | writeStream.end(); 12 | -------------------------------------------------------------------------------- /my-comp-lib-test/src/App.tsx: -------------------------------------------------------------------------------- 1 | import { Button } from "@guang-comp/react-comp-lib" 2 | import '@guang-comp/react-comp-lib/dist/index.css'; 3 | 4 | function App() { 5 | 6 | return
7 | 8 | 9 |
10 | } 11 | 12 | export default App 13 | -------------------------------------------------------------------------------- /my-websocket/src/index.js: -------------------------------------------------------------------------------- 1 | const MyWebSocket = require('./ws'); 2 | const ws = new MyWebSocket({ port: 8080 }); 3 | 4 | ws.on('data', (data) => { 5 | console.log('receive data:' + data); 6 | setInterval(() => { 7 | ws.send(data + ' ' + Date.now()); 8 | }, 2000) 9 | }); 10 | 11 | ws.on('close', (code, reason) => { 12 | console.log('close:', code, reason); 13 | }); 14 | -------------------------------------------------------------------------------- /my-git/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-git", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "commander": "^13.1.0", 14 | "glob": "^11.0.1" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /node-api-test/buffer.mjs: -------------------------------------------------------------------------------- 1 | import { Buffer } from 'node:buffer'; 2 | 3 | const buf1 = Buffer.alloc(10, 6); 4 | 5 | const buf2 = Buffer.from('神说要有光', 'utf-8'); 6 | 7 | const buf3 = Buffer.from([1, 2, 3]); 8 | 9 | console.log(buf1.toString('hex')) 10 | 11 | console.log(buf2.toString('utf-8')) 12 | console.log(buf2.toString('base64')) 13 | 14 | console.log(buf3.toString('hex')) 15 | -------------------------------------------------------------------------------- /react-comp/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /scaffold-pkg-test/src/semver.js: -------------------------------------------------------------------------------- 1 | const semver = require('semver'); 2 | 3 | if(semver.valid('1.2.3#')) { 4 | console.log('版本号有效'); 5 | } else { 6 | console.log('版本号无效'); 7 | } 8 | 9 | if(semver.gt('2.0.0', '1.0.8')) { 10 | console.log('有新版本可以安装') 11 | } 12 | 13 | if(semver.lte(process.version, '22.0.0')) { 14 | console.log(`node 版本 ${process.version} 小于 22`) 15 | } 16 | -------------------------------------------------------------------------------- /worker-test/node/index.js: -------------------------------------------------------------------------------- 1 | const { Worker, MessageChannel } = require('node:worker_threads'); 2 | 3 | const { port1, port2 } = new MessageChannel(); 4 | 5 | const worker = new Worker('./node-worker.js'); 6 | worker.postMessage( 7 | { value: 10*10000*10000, channel: port2 }, 8 | [port2] 9 | ); 10 | 11 | port1.on('message', (value) => { 12 | console.log('res', value); 13 | }) -------------------------------------------------------------------------------- /my-comp-lib-test/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /node-api-test/path2.js: -------------------------------------------------------------------------------- 1 | const path = require('node:path'); 2 | 3 | const filePath = path.join('../', 'node-api-test', './', 'path2.js'); 4 | 5 | console.log(filePath); 6 | 7 | const filePath2 = path.resolve('../', 'node-api-test', './', 'path2.js'); 8 | 9 | console.log(filePath2); 10 | 11 | console.log(path.relative('/a/b/c', '/a/d')); 12 | 13 | console.log(path.parse(__filename)); 14 | -------------------------------------------------------------------------------- /react-i18n-test/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /worker-test/node/node-worker.js: -------------------------------------------------------------------------------- 1 | const { parentPort } = require('node:worker_threads'); 2 | 3 | function calc(num) { 4 | let total = 0; 5 | for(let i = 0; i< num; i++) { 6 | total += i; 7 | } 8 | return total 9 | } 10 | 11 | parentPort.on('message', (message) => { 12 | const res = calc(message.value); 13 | 14 | message.channel.postMessage(res); 15 | }); 16 | -------------------------------------------------------------------------------- /guang-cli/packages/template-vue/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@guang-cli/template-vue", 3 | "version": "1.2.2", 4 | "publishConfig": { 5 | "access": "public" 6 | }, 7 | "main": "index.js", 8 | "scripts": { 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "keywords": [], 12 | "author": "", 13 | "license": "ISC", 14 | "description": "" 15 | } 16 | -------------------------------------------------------------------------------- /node-api-test/worker_threads_worker.mjs: -------------------------------------------------------------------------------- 1 | import { parentPort } from 'node:worker_threads'; 2 | 3 | function calc(num) { 4 | let total = 0; 5 | for(let i = 0; i< num; i++) { 6 | total += i; 7 | } 8 | return total 9 | } 10 | 11 | parentPort.on('message', (message) => { 12 | const res = calc(message.value); 13 | 14 | message.channel.postMessage(res); 15 | }); 16 | -------------------------------------------------------------------------------- /cli-args-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cli-args-test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "commander": "^12.1.0", 14 | "minimist": "^1.2.8" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /guang-cli/packages/template-react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@guang-cli/template-react", 3 | "version": "1.3.2", 4 | "publishConfig": { 5 | "access": "public" 6 | }, 7 | "main": "index.js", 8 | "scripts": { 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "keywords": [], 12 | "author": "", 13 | "license": "ISC", 14 | "description": "" 15 | } 16 | -------------------------------------------------------------------------------- /my-create-vite/template-vue/_gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /my-source-map-support/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "types": [ "node" ], 5 | "target": "es2016", 6 | "module": "NodeNext", 7 | "moduleResolution": "NodeNext", 8 | "esModuleInterop": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "strict": true, 11 | "skipLibCheck": true, 12 | "sourceMap": true 13 | } 14 | } -------------------------------------------------------------------------------- /my-create-vite/template-react-ts/_gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /my-create-vite/template-react/_gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /my-create-vite/template-vue-ts/_gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /node-api-test/worker_threads_main.mjs: -------------------------------------------------------------------------------- 1 | import { Worker, MessageChannel } from 'node:worker_threads'; 2 | 3 | const { port1, port2 } = new MessageChannel(); 4 | 5 | const worker = new Worker('./worker_threads_worker.mjs'); 6 | worker.postMessage( 7 | { value: 10*10000*10000, channel: port2 }, 8 | [port2] 9 | ); 10 | 11 | port1.on('message', (value) => { 12 | console.log('res', value); 13 | }) -------------------------------------------------------------------------------- /pnpm-monorepo-test/packages/cli/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "types": [ "node" ], 5 | "target": "es2016", 6 | "module": "NodeNext", 7 | "moduleResolution": "NodeNext", 8 | "declaration": true, 9 | "esModuleInterop": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "strict": true, 12 | "skipLibCheck": true, 13 | } 14 | } -------------------------------------------------------------------------------- /pnpm-monorepo-test/packages/core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "types": [ "node" ], 5 | "target": "es2016", 6 | "module": "NodeNext", 7 | "moduleResolution": "NodeNext", 8 | "declaration": true, 9 | "esModuleInterop": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "strict": true, 12 | "skipLibCheck": true, 13 | } 14 | } -------------------------------------------------------------------------------- /ansi-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ansi-test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "ansi-escapes": "^7.0.0", 15 | "chalk": "^5.3.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /guang-cli/packages/template-react/template/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /guang-cli/packages/template-vue/template/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /my-create-vite/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "types": [ "node" ], 5 | "target": "es2016", 6 | "module": "NodeNext", 7 | "moduleResolution": "NodeNext", 8 | "esModuleInterop": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "strict": true, 11 | "skipLibCheck": true, 12 | }, 13 | "exclude": [ 14 | "template-**" 15 | ] 16 | } -------------------------------------------------------------------------------- /my-nest-cli/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "types": [ "node" ], 5 | "target": "es2016", 6 | "module": "NodeNext", 7 | "moduleResolution": "NodeNext", 8 | "esModuleInterop": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "strict": true, 11 | "skipLibCheck": true, 12 | }, 13 | "exclude": [ 14 | "nest-project" 15 | ] 16 | } -------------------------------------------------------------------------------- /blessed-contrib-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "blessed-contrib-test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "blessed": "^0.1.81", 14 | "blessed-contrib": "^4.11.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /buffer-test/index.js: -------------------------------------------------------------------------------- 1 | const buffer = new ArrayBuffer(10); 2 | 3 | const arr1 = new Uint16Array(buffer); 4 | 5 | arr1[0] = 256; 6 | console.log(arr1) 7 | console.log(arr1.length); 8 | console.log(arr1.byteLength); 9 | 10 | const arr2 = new Uint8Array(buffer); 11 | console.log(arr2); 12 | console.log(arr2.length); 13 | console.log(arr2.byteLength); -------------------------------------------------------------------------------- /ansi-test/index3.js: -------------------------------------------------------------------------------- 1 | import ansiEscapes from 'ansi-escapes'; 2 | 3 | const log = process.stdout.write.bind(process.stdout); 4 | 5 | log(ansiEscapes.cursorTo(10, 1) + '111'); 6 | log(ansiEscapes.cursorTo(7, 2) + '222'); 7 | log(ansiEscapes.cursorTo(5, 3) + '333'); 8 | 9 | setTimeout(() => { 10 | log(ansiEscapes.cursorTo(0, 2) + ansiEscapes.eraseEndLine); 11 | log(ansiEscapes.cursorTo(5, 3) + '444') 12 | }, 1000) 13 | -------------------------------------------------------------------------------- /node-api-test/util4.mjs: -------------------------------------------------------------------------------- 1 | import util from 'node:util'; 2 | import cp from 'node:child_process'; 3 | 4 | // cp.exec('ls -l', (stderr, stdout) => { 5 | // console.log(stdout); 6 | // }); 7 | 8 | const exec = util.promisify(cp.exec); 9 | 10 | async function main() { 11 | const { stdout, stderr } = await exec('ls -l'); 12 | console.log('stdout:', stdout); 13 | console.error('stderr:', stderr); 14 | } 15 | main(); 16 | -------------------------------------------------------------------------------- /guang-cli/packages/cli/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "types": [ "node" ], 5 | "target": "es2016", 6 | "module": "NodeNext", 7 | "moduleResolution": "NodeNext", 8 | "declaration": true, 9 | "esModuleInterop": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "strict": true, 12 | "skipLibCheck": true, 13 | "sourceMap": true 14 | } 15 | } -------------------------------------------------------------------------------- /guang-cli/packages/utils/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "types": [ "node" ], 5 | "target": "es2016", 6 | "module": "NodeNext", 7 | "moduleResolution": "NodeNext", 8 | "declaration": true, 9 | "esModuleInterop": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "strict": true, 12 | "skipLibCheck": true, 13 | "sourceMap": true 14 | }, 15 | } -------------------------------------------------------------------------------- /my-create-vite/template-vue/README.md: -------------------------------------------------------------------------------- 1 | # Vue 3 + Vite 2 | 3 | This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 ` 12 | 13 | 14 | -------------------------------------------------------------------------------- /jd-spider/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jd-spider", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "puppeteer": "^22.7.1", 15 | "sqlite": "^5.1.1", 16 | "sqlite3": "^5.1.7" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /react-i18n-test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + React + TS 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /guang-cli/packages/template-react/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @guang-cli/template-react 2 | 3 | ## 1.3.2 4 | 5 | ### Patch Changes 6 | 7 | - generate command 8 | 9 | ## 1.3.1 10 | 11 | ### Patch Changes 12 | 13 | - generate + config 14 | 15 | ## 1.3.0 16 | 17 | ### Minor Changes 18 | 19 | - eslint 20 | 21 | ## 1.2.0 22 | 23 | ### Minor Changes 24 | 25 | - ejs template 26 | 27 | ## 1.1.0 28 | 29 | ### Minor Changes 30 | 31 | - guang-cli 项目模版 32 | -------------------------------------------------------------------------------- /my-comp-lib-test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + React + TS 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /my-create-vite/template-vue/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + Vue 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /my-create-vite/template-react/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + React 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /pnpm-monorepo-test/packages/core/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@guang-pnpm/core", 3 | "version": "1.1.0", 4 | "description": "", 5 | "type": "module", 6 | "main": "dist/index.js", 7 | "types": "dist/index.d.ts", 8 | "publishConfig": { 9 | "access": "public" 10 | }, 11 | "scripts": { 12 | "test": "echo \"Error: no test specified\" && exit 1" 13 | }, 14 | "keywords": [], 15 | "author": "", 16 | "license": "ISC" 17 | } 18 | -------------------------------------------------------------------------------- /react-comp/src/Button/index.scss: -------------------------------------------------------------------------------- 1 | .btn { 2 | padding: 8px 10px; 3 | 4 | display: inline-block; 5 | border-radius: 4px; 6 | cursor: pointer; 7 | 8 | &-primary { 9 | background: skyblue; 10 | &:hover { 11 | background: lightblue; 12 | } 13 | } 14 | &-default { 15 | border: 1px solid skyblue; 16 | &:hover { 17 | color: skyblue; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /cli-progress-test/src/index2.ts: -------------------------------------------------------------------------------- 1 | import { clearTimeout } from 'timers'; 2 | import { ProgressBar } from './ProgressBar.js'; 3 | 4 | const bar = new ProgressBar(); 5 | 6 | bar.start(200, 0); 7 | 8 | let value = 0; 9 | 10 | const timer = setInterval(function(){ 11 | value++; 12 | 13 | bar.update(value); 14 | 15 | if(value > bar.getTotalSize()) { 16 | clearTimeout(timer); 17 | bar.stop(); 18 | } 19 | }, 20); 20 | 21 | 22 | -------------------------------------------------------------------------------- /my-create-vite/template-vue-ts/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + Vue + TS 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /react-comp-lib/src/Button/index.scss: -------------------------------------------------------------------------------- 1 | .btn { 2 | padding: 8px 10px; 3 | 4 | display: inline-block; 5 | border-radius: 4px; 6 | cursor: pointer; 7 | 8 | &-primary { 9 | background: skyblue; 10 | &:hover { 11 | background: lightblue; 12 | } 13 | } 14 | &-default { 15 | border: 1px solid skyblue; 16 | &:hover { 17 | color: skyblue; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /stream-test/src/zlib.mjs: -------------------------------------------------------------------------------- 1 | import { 2 | createReadStream, 3 | createWriteStream, 4 | } from 'node:fs'; 5 | import { pipeline } from 'node:stream'; 6 | import { createGzip } from 'node:zlib'; 7 | 8 | const gzip = createGzip(); 9 | const source = createReadStream(import.meta.dirname + '/data.txt'); 10 | const destination = createWriteStream('data.txt.gz'); 11 | 12 | // source.pipe(gzip).pipe(destination); 13 | pipeline(source, gzip, destination) 14 | -------------------------------------------------------------------------------- /my-create-vite/template-react-ts/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + React + TS 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /sqlite-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sqlite-test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "@types/node": "^22.10.1" 14 | }, 15 | "dependencies": { 16 | "sqlite": "^5.1.1", 17 | "sqlite3": "^5.1.7" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /guang-cli/packages/template-vue/template/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + Vue + TS 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /guang-cli/packages/template-react/template/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + React + TS 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /node-api-test/events.js: -------------------------------------------------------------------------------- 1 | const EventEmitter = require('node:events'); 2 | 3 | class MyEmitter extends EventEmitter {} 4 | 5 | const myEmitter = new MyEmitter(); 6 | 7 | myEmitter.on('aaa', (data) => { 8 | console.log('aaa 事件触发', data); 9 | }); 10 | 11 | myEmitter.once('bbb', (data) => { 12 | console.log('bbb 事件触发', data); 13 | }); 14 | 15 | myEmitter.emit('aaa', 1); 16 | myEmitter.emit('aaa', 2); 17 | myEmitter.emit('bbb', 3); 18 | myEmitter.emit('bbb', 4); 19 | -------------------------------------------------------------------------------- /node-api-test/net-tcp-client.mjs: -------------------------------------------------------------------------------- 1 | import net from 'node:net'; 2 | 3 | const socket = net.createConnection({ 4 | host: 'localhost', 5 | port: 6666 6 | }, () => { 7 | console.log('连接到了服务端!'); 8 | 9 | socket.write('world!\n'); 10 | 11 | setTimeout(()=> { 12 | socket.end(); 13 | }, 2000); 14 | }); 15 | 16 | socket.on('data', (data) => { 17 | console.log(data.toString()); 18 | }); 19 | 20 | socket.on('end', () => { 21 | console.log('断开连接'); 22 | }); -------------------------------------------------------------------------------- /guang-cli/packages/create/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "types": [ "node" ], 5 | "target": "es2016", 6 | "module": "NodeNext", 7 | "moduleResolution": "NodeNext", 8 | "declaration": true, 9 | "esModuleInterop": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "strict": true, 12 | "skipLibCheck": true, 13 | "sourceMap": true 14 | }, 15 | "include": [ 16 | "src/**/*" 17 | ] 18 | } -------------------------------------------------------------------------------- /stream-test/src/socket-client.mjs: -------------------------------------------------------------------------------- 1 | import net from 'node:net'; 2 | 3 | const socket = net.createConnection({ 4 | host: 'localhost', 5 | port: 6666 6 | }, () => { 7 | console.log('连接到了服务端!'); 8 | 9 | socket.write('world!\n'); 10 | 11 | setTimeout(()=> { 12 | socket.end(); 13 | }, 2000); 14 | }); 15 | 16 | socket.on('data', (data) => { 17 | console.log(data.toString()); 18 | }); 19 | 20 | socket.on('end', () => { 21 | console.log('断开连接'); 22 | }); 23 | -------------------------------------------------------------------------------- /guang-cli/packages/generate/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "types": [ "node" ], 5 | "target": "es2016", 6 | "module": "NodeNext", 7 | "moduleResolution": "NodeNext", 8 | "declaration": true, 9 | "esModuleInterop": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "strict": true, 12 | "skipLibCheck": true, 13 | "sourceMap": true 14 | }, 15 | "include": [ 16 | "src/**/*.ts" 17 | ] 18 | } -------------------------------------------------------------------------------- /my-create-vite/template-vue-ts/README.md: -------------------------------------------------------------------------------- 1 | # Vue 3 + TypeScript + Vite 2 | 3 | This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 ` 19 | 20 | -------------------------------------------------------------------------------- /my-create-vite/template-react/README.md: -------------------------------------------------------------------------------- 1 | # React + Vite 2 | 3 | This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. 4 | 5 | Currently, two official plugins are available: 6 | 7 | - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh 8 | - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh 9 | -------------------------------------------------------------------------------- /cli-dashboard/test.js: -------------------------------------------------------------------------------- 1 | import si from 'systeminformation'; 2 | 3 | si.currentLoad(data => { 4 | // console.log(data); 5 | }); 6 | 7 | si.fsSize(data => { 8 | // console.log(data); 9 | }); 10 | 11 | si.mem(data => { 12 | // console.log(data); 13 | }) 14 | 15 | si.networkInterfaceDefault(iface => { 16 | // console.log(iface); 17 | si.networkStats(iface, data => { 18 | // console.log(data); 19 | }); 20 | }); 21 | 22 | si.processes(data => { 23 | // console.log(data); 24 | }) -------------------------------------------------------------------------------- /my-source-map-support/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-source-map-support", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "@types/node": "^22.8.2", 15 | "typescript": "^5.6.3" 16 | }, 17 | "dependencies": { 18 | "source-map": "^0.6.1" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /sqlite-test/src/index4.mjs: -------------------------------------------------------------------------------- 1 | import sqlite3 from 'sqlite3' 2 | import { open } from 'sqlite' 3 | 4 | async function main() { 5 | const db = await open({ 6 | filename: 'data.db', 7 | driver: sqlite3.Database 8 | }); 9 | 10 | const person = await db.get('select * from student WHERE name = :name', { 11 | ':name': '张三' 12 | }) 13 | console.log(person); 14 | 15 | const allData = await db.all('SELECT * FROM student'); 16 | console.log(allData); 17 | } 18 | 19 | main(); 20 | -------------------------------------------------------------------------------- /my-create-vite/template-vue-ts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vite-vue-typescript-starter", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "vue-tsc -b && vite build", 9 | "preview": "vite preview" 10 | }, 11 | "dependencies": { 12 | "vue": "^3.5.10" 13 | }, 14 | "devDependencies": { 15 | "@vitejs/plugin-vue": "^5.1.4", 16 | "typescript": "^5.5.3", 17 | "vite": "^5.4.8", 18 | "vue-tsc": "^2.1.6" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /my-create-vite/template-vue/src/assets/vue.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sqlite-test/src/many-many-query.mjs: -------------------------------------------------------------------------------- 1 | import sqlite3 from 'sqlite3' 2 | import { open } from 'sqlite' 3 | 4 | async function main() { 5 | const db = await open({ 6 | filename: '1-many.db', 7 | driver: sqlite3.Database 8 | }); 9 | 10 | const allData = await db.all(` 11 | SELECT * FROM article a 12 | JOIN article_tag at ON a.id = at.article_id 13 | JOIN tag t ON t.id = at.tag_id 14 | WHERE a.id = 1 15 | `); 16 | console.log(allData); 17 | 18 | } 19 | 20 | main(); 21 | -------------------------------------------------------------------------------- /keyboard-control/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "keyboard-control", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "@types/node": "^22.5.2", 15 | "typescript": "^5.5.4" 16 | }, 17 | "dependencies": { 18 | "ansi-escapes": "^7.0.0", 19 | "chalk": "^5.3.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /my-create-vite/template-vue-ts/src/assets/vue.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /my-websocket/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /scan-thread-pool/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "scan-thread-pool", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "@types/node": "^22.5.2", 15 | "typescript": "^5.5.4" 16 | }, 17 | "dependencies": { 18 | "get-folder-size": "^5.0.0", 19 | "rxjs": "^7.8.1" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /guang-cli/packages/template-vue/template/src/assets/vue.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scaffold-pkg-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "scaffold-pkg-test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "@inquirer/prompts": "^7.0.1", 14 | "cli-spinner": "^0.2.10", 15 | "fs-extra": "^11.2.0", 16 | "glob": "^11.0.0", 17 | "npminstall": "^7.12.0", 18 | "semver": "^7.6.3" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /mini-puppeteer/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mini-puppeteer", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "puppeteer": { 7 | "chromium_revision": "970501" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1" 11 | }, 12 | "keywords": [], 13 | "author": "", 14 | "license": "ISC", 15 | "dependencies": { 16 | "chrome-remote-interface": "^0.33.2", 17 | "extract-zip": "^2.0.1", 18 | "fs-extra": "^11.2.0", 19 | "progress": "^2.0.3" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /guang-cli/.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /node-api-test/sqlite.mjs: -------------------------------------------------------------------------------- 1 | import { DatabaseSync } from 'node:sqlite'; 2 | const database = new DatabaseSync('data.db'); 3 | 4 | database.exec(` 5 | CREATE TABLE student( 6 | id INTEGER PRIMARY KEY, 7 | name TEXT, 8 | age INT 9 | ) STRICT 10 | `); 11 | 12 | const insert = database.prepare('INSERT INTO student (id, name, age) VALUES (?, ?, ?)'); 13 | insert.run(1, '张三', 20); 14 | insert.run(2, '李四', 21); 15 | insert.run(3, '王五', 22); 16 | 17 | const query = database.prepare('SELECT * FROM student ORDER BY id'); 18 | console.log(query.all()); 19 | -------------------------------------------------------------------------------- /guang-cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "guang-cli", 3 | "version": "1.0.0", 4 | "description": "", 5 | "private": true, 6 | "main": "index.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "@changesets/cli": "^2.27.9", 15 | "@types/node": "^22.8.6", 16 | "prettier-plugin-organize-imports": "^4.1.0", 17 | "prettier-plugin-packagejson": "^2.5.3", 18 | "typescript": "^5.6.3" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /guang-cli/packages/create/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @guang-cli/create 2 | 3 | ## 0.3.1 4 | 5 | ### Patch Changes 6 | 7 | - Updated dependencies 8 | - @guang-cli/utils@1.1.2 9 | 10 | ## 0.3.0 11 | 12 | ### Minor Changes 13 | 14 | - create 15 | 16 | ## 0.2.0 17 | 18 | ### Minor Changes 19 | 20 | - create 21 | 22 | ## 0.1.0 23 | 24 | ### Minor Changes 25 | 26 | - create 27 | 28 | ## 0.0.3 29 | 30 | ### Patch Changes 31 | 32 | - Updated dependencies 33 | - @guang-cli/utils@1.1.1 34 | 35 | ## 0.0.2 36 | 37 | ### Patch Changes 38 | 39 | - cli create 包初始化 40 | -------------------------------------------------------------------------------- /pnpm-monorepo-test/.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /scan-thread-pool/src/test.ts: -------------------------------------------------------------------------------- 1 | import { filter, map, Subject } from 'rxjs'; 2 | 3 | const stream$ = new Subject(); 4 | 5 | const result$ = stream$ 6 | .pipe(map((x) => x * x)) 7 | .pipe(filter((x) => x % 2 !== 0)); 8 | 9 | result$.subscribe((v) => { 10 | console.log(`监听者1: ${v}`) 11 | }); 12 | 13 | result$.subscribe((v) => { 14 | console.log(`监听者2: ${v}`) 15 | }); 16 | 17 | stream$.next(1); 18 | 19 | setTimeout(() => { 20 | stream$.next(2); 21 | }, 1000); 22 | 23 | setTimeout(() => { 24 | stream$.next(3); 25 | }, 2000); 26 | 27 | -------------------------------------------------------------------------------- /stream-test/src/readable2.mjs: -------------------------------------------------------------------------------- 1 | import { Readable } from 'node:stream'; 2 | 3 | class ReadableDong extends Readable { 4 | 5 | _read() { 6 | this.push('阿门阿前一棵葡萄树,'); 7 | this.push('阿东阿东绿的刚发芽,'); 8 | this.push('阿东背着那重重的的壳呀,'); 9 | this.push('一步一步地往上爬。') 10 | this.push(null); 11 | } 12 | 13 | } 14 | 15 | const readableStream = new ReadableDong(); 16 | 17 | readableStream.on('data', (data)=> { 18 | console.log(data.toString()) 19 | }); 20 | 21 | readableStream.on('end', () => { 22 | console.log('done'); 23 | }); -------------------------------------------------------------------------------- /sqlite-test/src/index.mjs: -------------------------------------------------------------------------------- 1 | import { DatabaseSync } from 'node:sqlite'; 2 | const database = new DatabaseSync('data.db'); 3 | 4 | database.exec(` 5 | CREATE TABLE student( 6 | id INTEGER PRIMARY KEY, 7 | name TEXT, 8 | age INT 9 | ) STRICT 10 | `); 11 | 12 | const insert = database.prepare('INSERT INTO student (id, name, age) VALUES (?, ?, ?)'); 13 | insert.run(1, '张三', 20); 14 | insert.run(2, '李四', 21); 15 | insert.run(3, '王五', 22); 16 | 17 | const query = database.prepare('SELECT * FROM student ORDER BY id'); 18 | console.log(query.all()); 19 | 20 | -------------------------------------------------------------------------------- /blessed-contrib-test/src/bar.js: -------------------------------------------------------------------------------- 1 | const blessed = require('blessed'); 2 | const contrib = require('blessed-contrib'); 3 | 4 | const screen = blessed.screen({ 5 | fullUnicode: true 6 | }); 7 | 8 | const bar = contrib.bar({ 9 | label: '气温变化', 10 | barWidth: 8, 11 | barSpacing: 20, 12 | maxHeight: 20 13 | }) 14 | 15 | screen.append(bar) 16 | 17 | bar.setData({ 18 | titles: ['10.1', '10.2', '10.3', '10.4'], 19 | data: [6, 13, 8, 10] 20 | }) 21 | 22 | screen.key('C-c', function() { 23 | screen.destroy(); 24 | }); 25 | 26 | screen.render(); 27 | -------------------------------------------------------------------------------- /node-api-test/net-tcp-server.mjs: -------------------------------------------------------------------------------- 1 | import net from 'node:net'; 2 | 3 | const server = net.createServer(function(clientSocket){ 4 | console.log('新的客户端 socket 连接'); 5 | 6 | clientSocket.on('data', function(data){ 7 | console.log(data.toString()); 8 | 9 | clientSocket.write('hello'); 10 | }); 11 | 12 | clientSocket.on('end', function(){ 13 | console.log('连接中断'); 14 | }); 15 | }); 16 | 17 | server.listen(6666, 'localhost', function(){ 18 | const address = server.address(); 19 | 20 | console.log('被监听的地址为:%j', address); 21 | }); -------------------------------------------------------------------------------- /node-api-test/util2.mjs: -------------------------------------------------------------------------------- 1 | import util from 'node:util'; 2 | 3 | function bbb() { 4 | const callSites = util.getCallSites(); 5 | 6 | callSites.forEach((callSite, index) => { 7 | console.log(`CallSite ${index + 1}:`); 8 | console.log(`Function Name: ${callSite.functionName}`); 9 | console.log(`Script Name: ${callSite.scriptName}`); 10 | console.log(`Line Number: ${callSite.lineNumber}`); 11 | console.log(`Column Number: ${callSite.column}`); 12 | console.log() 13 | }); 14 | } 15 | 16 | function aaa() { 17 | bbb(); 18 | } 19 | 20 | aaa(); 21 | -------------------------------------------------------------------------------- /pnpm-monorepo-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pnpm-monorepo-test", 3 | "version": "1.0.0", 4 | "private": true, 5 | "description": "", 6 | "main": "index.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "@changesets/cli": "^2.27.8", 15 | "@types/node": "^22.5.5", 16 | "prettier-plugin-organize-imports": "^4.0.0", 17 | "prettier-plugin-packagejson": "^2.5.2", 18 | "typescript": "^5.6.2" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /cli-args-test/index3.js: -------------------------------------------------------------------------------- 1 | const { Command } = require('commander'); 2 | const program = new Command(); 3 | 4 | program 5 | .name('string-util') 6 | .description('一些字符串工具的 CLI') 7 | .version('0.8.0'); 8 | 9 | program.command('split') 10 | .description('分割字符串为字符数组') 11 | .argument('string', '分割的字符串') 12 | .option('--first', '只展示第一个子串') 13 | .option('-s, --separator ', '分割字符', ',') 14 | .action((str, options) => { 15 | 16 | const limit = options.first ? 1 : undefined; 17 | console.log(str.split(options.separator, limit)); 18 | }); 19 | 20 | program.parse(); -------------------------------------------------------------------------------- /jd-spider/create-table.js: -------------------------------------------------------------------------------- 1 | import sqlite3 from 'sqlite3' 2 | import { open } from 'sqlite' 3 | 4 | async function main() { 5 | const db = await open({ 6 | filename: 'data.db', 7 | driver: sqlite3.Database 8 | }); 9 | 10 | await db.exec(` 11 | CREATE TABLE "job" ( 12 | "id" INTEGER, 13 | "name" TEXT, 14 | "area" TEXT, 15 | "salary" TEXT, 16 | "link" TEXT, 17 | "company" TEXT, 18 | "desc" TEXT, 19 | PRIMARY KEY("id" AUTOINCREMENT) 20 | ); 21 | `); 22 | } 23 | 24 | main(); 25 | -------------------------------------------------------------------------------- /rollup-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rollup-test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "css-loader": "^7.1.2", 14 | "mini-css-extract-plugin": "^2.9.2", 15 | "rollup": "^4.27.2", 16 | "rollup-plugin-postcss": "^4.0.2", 17 | "style-loader": "^4.0.0", 18 | "webpack": "^5.96.1", 19 | "webpack-cli": "^5.1.4" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /stream-test/src/socket-server.mjs: -------------------------------------------------------------------------------- 1 | import net from 'node:net'; 2 | 3 | const server = net.createServer(function(clientSocket){ 4 | console.log('新的客户端 socket 连接'); 5 | 6 | clientSocket.on('data', function(data){ 7 | console.log(data.toString()); 8 | 9 | clientSocket.write('hello'); 10 | }); 11 | 12 | clientSocket.on('end', function(){ 13 | console.log('连接中断'); 14 | }); 15 | }); 16 | 17 | server.listen(6666, 'localhost', function(){ 18 | const address = server.address(); 19 | 20 | console.log('被监听的地址为:%j', address); 21 | }); 22 | -------------------------------------------------------------------------------- /scan-thread-pool/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Subject } from "rxjs"; 2 | import { ScanService } from "./scan.js"; 3 | import getFolderSize from "get-folder-size"; 4 | 5 | const service = new ScanService(); 6 | 7 | const stream$ = new Subject(); 8 | 9 | service.startScan(stream$, '/Users/guang'); 10 | 11 | stream$.subscribe(async (value) => { 12 | console.log('订阅者收到了扫描结果:', value, await getSize(value)) 13 | }) 14 | 15 | async function getSize(path: string) { 16 | const res = await getFolderSize(path); 17 | 18 | return (res.size / 1024 / 1024).toFixed(2) + 'M'; 19 | } 20 | -------------------------------------------------------------------------------- /node-api-test/url2.mjs: -------------------------------------------------------------------------------- 1 | import http from 'node:http'; 2 | import url from 'node:url'; 3 | 4 | // const options = { 5 | // method: 'GET', 6 | // host: 'www.baidu.com', 7 | // port: 80, 8 | // path: '/' 9 | // }; 10 | 11 | const options = url.urlToHttpOptions(new URL('http://www.baidu.com:80/')); 12 | 13 | console.log(options); 14 | 15 | const req = http.request(options, res => { 16 | res.on('data', (chunk) => { 17 | console.log(chunk.toString()); 18 | }); 19 | res.on('end', () => { 20 | console.log('done'); 21 | }); 22 | }); 23 | 24 | req.end(); 25 | -------------------------------------------------------------------------------- /buffer-test/index2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /cli-dashboard/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "type": "node", 6 | "request": "launch", 7 | "name": "debug test.js", 8 | "console": "integratedTerminal", 9 | "program": "${workspaceFolder}/test.js", 10 | }, 11 | { 12 | "type": "node", 13 | "request": "launch", 14 | "name": "debug test.js2", 15 | "console": "integratedTerminal", 16 | "program": "${workspaceFolder}/dist/index.js", 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /cli-dashboard/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cli-dashboard", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "@types/blessed": "^0.1.25", 15 | "@types/node": "^22.7.9", 16 | "typescript": "^5.6.3" 17 | }, 18 | "dependencies": { 19 | "blessed": "^0.1.81", 20 | "blessed-contrib": "^4.11.0", 21 | "systeminformation": "^5.23.5" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cli-progress-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cli-progress-test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "ansi-escapes": "^7.0.0", 15 | "chalk": "^5.3.0", 16 | "cli-progress": "^3.12.0" 17 | }, 18 | "devDependencies": { 19 | "@types/cli-progress": "^3.11.6", 20 | "@types/node": "^22.5.2", 21 | "typescript": "^5.5.4" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /react-i18n-test/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2022", 4 | "lib": ["ES2023"], 5 | "module": "ESNext", 6 | "skipLibCheck": true, 7 | 8 | /* Bundler mode */ 9 | "moduleResolution": "bundler", 10 | "allowImportingTsExtensions": true, 11 | "isolatedModules": true, 12 | "moduleDetection": "force", 13 | "noEmit": true, 14 | 15 | /* Linting */ 16 | "strict": true, 17 | "noUnusedLocals": true, 18 | "noUnusedParameters": true, 19 | "noFallthroughCasesInSwitch": true 20 | }, 21 | "include": ["vite.config.ts"] 22 | } 23 | -------------------------------------------------------------------------------- /node-api-test/readline2.mjs: -------------------------------------------------------------------------------- 1 | 2 | import { createInterface } from 'node:readline'; 3 | import { exit, stdin, stdout } from 'node:process'; 4 | 5 | const rl = createInterface({ 6 | input: stdin, 7 | output: stdout, 8 | prompt: 'guang> ', 9 | }); 10 | 11 | rl.prompt(); 12 | 13 | rl.on('line', (line) => { 14 | switch (line.trim()) { 15 | case 'hello': 16 | console.log('world!'); 17 | break; 18 | default: 19 | console.log(`你说啥?我听到的是 '${line.trim()}'`); 20 | break; 21 | } 22 | rl.prompt(); 23 | }).on('close', () => { 24 | console.log('bye!'); 25 | exit(0); 26 | }); 27 | -------------------------------------------------------------------------------- /my-prompts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-prompts", 3 | "version": "1.0.0", 4 | "type": "module", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "@types/node": "^22.5.3", 14 | "@types/prompts": "^2.4.9", 15 | "typescript": "^5.5.4" 16 | }, 17 | "dependencies": { 18 | "ansi-escapes": "^7.0.0", 19 | "chalk": "^5.3.0", 20 | "prompts": "^2.4.2", 21 | "undici-types": "^6.19.8" 22 | }, 23 | "description": "" 24 | } 25 | -------------------------------------------------------------------------------- /scaffold-pkg-test/src/inquirer.mjs: -------------------------------------------------------------------------------- 1 | import { input, select, password } from '@inquirer/prompts'; 2 | 3 | const name = await input({ message: '请输入你的名字' }); 4 | 5 | const job = await select({ 6 | message: '选择你的职业', 7 | choices: [ 8 | { 9 | name: '教师', 10 | value: '教师', 11 | description: '11111', 12 | }, 13 | { 14 | name: '医生', 15 | value: '医生', 16 | description: '22222', 17 | } 18 | ], 19 | }); 20 | 21 | const pass = await password({ message: '请输入密码' }); 22 | 23 | console.log({ 24 | name, 25 | job, 26 | pass 27 | }) 28 | 29 | -------------------------------------------------------------------------------- /my-create-vite/template-react-ts/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2022", 4 | "lib": ["ES2023"], 5 | "module": "ESNext", 6 | "skipLibCheck": true, 7 | 8 | /* Bundler mode */ 9 | "moduleResolution": "bundler", 10 | "allowImportingTsExtensions": true, 11 | "isolatedModules": true, 12 | "moduleDetection": "force", 13 | "noEmit": true, 14 | 15 | /* Linting */ 16 | "strict": true, 17 | "noUnusedLocals": true, 18 | "noUnusedParameters": true, 19 | "noFallthroughCasesInSwitch": true 20 | }, 21 | "include": ["vite.config.ts"] 22 | } 23 | -------------------------------------------------------------------------------- /my-create-vite/template-vue-ts/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2022", 4 | "lib": ["ES2023"], 5 | "module": "ESNext", 6 | "skipLibCheck": true, 7 | 8 | /* Bundler mode */ 9 | "moduleResolution": "bundler", 10 | "allowImportingTsExtensions": true, 11 | "isolatedModules": true, 12 | "moduleDetection": "force", 13 | "noEmit": true, 14 | 15 | /* Linting */ 16 | "strict": true, 17 | "noUnusedLocals": true, 18 | "noUnusedParameters": true, 19 | "noFallthroughCasesInSwitch": true 20 | }, 21 | "include": ["vite.config.ts"] 22 | } 23 | -------------------------------------------------------------------------------- /react-i18n-test/src/main.tsx: -------------------------------------------------------------------------------- 1 | import { createRoot } from 'react-dom/client' 2 | import App from './App.tsx' 3 | import './index.css' 4 | import { IntlProvider } from 'react-intl'; 5 | import zhCN from './locales/zh-CN.json'; 6 | import enUS from './locales/en-US.json'; 7 | 8 | const messages: Record = { 9 | 'en-US': enUS, 10 | 'zh-CN': zhCN 11 | } 12 | 13 | const locale = navigator.language; 14 | 15 | createRoot(document.getElementById('root')!).render( 16 | 20 | 21 | 22 | ) 23 | -------------------------------------------------------------------------------- /blessed-contrib-test/src/map.js: -------------------------------------------------------------------------------- 1 | const blessed = require('blessed'); 2 | const contrib = require('blessed-contrib'); 3 | 4 | const screen = blessed.screen({ 5 | fullUnicode: true 6 | }); 7 | 8 | const map = contrib.map({label: '世界地图'}); 9 | screen.append(map); 10 | 11 | map.addMarker({ 12 | lon : "-79.0000", 13 | lat : "37.5000", 14 | color: "red", 15 | char: "❌" 16 | }) 17 | 18 | map.addMarker({ 19 | lon : "-59.0000", 20 | lat : "20.5000", 21 | color: "red", 22 | char: "✅" 23 | }) 24 | 25 | screen.key('C-c', function() { 26 | screen.destroy(); 27 | }); 28 | 29 | screen.render(); 30 | -------------------------------------------------------------------------------- /my-create-vite/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-create-vite", 3 | "version": "1.0.0", 4 | "description": "", 5 | "type": "module", 6 | "main": "index.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "chalk": "^5.3.0", 15 | "minimist": "^1.2.8", 16 | "prompts": "^2.4.2" 17 | }, 18 | "devDependencies": { 19 | "@types/minimist": "^1.2.5", 20 | "@types/node": "^22.7.4", 21 | "@types/prompts": "^2.4.9", 22 | "typescript": "^5.6.2" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /node-api-test/url.mjs: -------------------------------------------------------------------------------- 1 | import url from 'node:url'; 2 | 3 | const myURL = 4 | new url.URL('https://user:pass@sub.example.com:8080/xxx/yyy?a=1&b=2#hash'); 5 | 6 | console.log(myURL.hash, myURL.host, myURL.searchParams); 7 | 8 | console.log(myURL.searchParams.get('a')); 9 | 10 | myURL.searchParams.set('b', 222); 11 | myURL.searchParams.append('c', 333); 12 | 13 | console.log(myURL.searchParams.toString()) 14 | 15 | const params = new url.URLSearchParams('?aa=1&bb=2'); 16 | console.log(params); 17 | for (const [name, value] of params) { 18 | console.log(name, value); 19 | } 20 | 21 | console.log(url.urlToHttpOptions(myURL)); -------------------------------------------------------------------------------- /pnpm-monorepo-test/packages/cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@guang-pnpm/cli", 3 | "version": "1.1.0", 4 | "description": "", 5 | "type": "module", 6 | "main": "dist/index.js", 7 | "types": "dist/index.d.ts", 8 | "bin": { 9 | "num-cli": "./dist/index.js" 10 | }, 11 | "publishConfig": { 12 | "access": "public" 13 | }, 14 | "scripts": { 15 | "test": "echo \"Error: no test specified\" && exit 1" 16 | }, 17 | "keywords": [], 18 | "author": "", 19 | "license": "ISC", 20 | "dependencies": { 21 | "@guang-pnpm/core": "workspace:^", 22 | "chalk": "^5.3.0", 23 | "commander": "^12.1.0" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /scaffold-pkg-test/src/fs.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | 4 | function copyDir(srcDir, destDir) { 5 | fs.mkdirSync(destDir, { recursive: true }) 6 | for (const file of fs.readdirSync(srcDir)) { 7 | const srcFile = path.resolve(srcDir, file) 8 | const destFile = path.resolve(destDir, file) 9 | copy(srcFile, destFile) 10 | } 11 | } 12 | 13 | function copy(src, dest) { 14 | const stat = fs.statSync(src) 15 | if (stat.isDirectory()) { 16 | copyDir(src, dest) 17 | } else { 18 | fs.copyFileSync(src, dest) 19 | } 20 | } 21 | 22 | copyDir('./src', './aaa/bbb'); 23 | -------------------------------------------------------------------------------- /my-prompts/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Launch Program", 11 | "console": "integratedTerminal", 12 | "skipFiles": [ 13 | "/**" 14 | ], 15 | "program": "${workspaceFolder}/dist/test2.js", 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /worker-test/pool/pool-worker.js: -------------------------------------------------------------------------------- 1 | const { parentPort } = require('node:worker_threads'); 2 | 3 | function calc(num) { 4 | let total = 0; 5 | for(let i = 0; i< num; i++) { 6 | total += i; 7 | } 8 | return total 9 | } 10 | 11 | let tunnel; 12 | let id; 13 | 14 | parentPort.on('message', (message) => { 15 | if(message.type === 'startup') { 16 | id = message.id; 17 | tunnel = message.channel; 18 | 19 | tunnel.on('message', (msg) => { 20 | tunnel.postMessage({ 21 | id, 22 | res: calc(msg.value) 23 | }); 24 | }) 25 | } 26 | }); 27 | 28 | 29 | -------------------------------------------------------------------------------- /my-source-map-support/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "调试 node", 9 | "program": "${workspaceFolder}/src/index.ts", 10 | "request": "launch", 11 | "console": "integratedTerminal", 12 | "skipFiles": [ 13 | "/**" 14 | ], 15 | "type": "node" 16 | }, 17 | ] 18 | } -------------------------------------------------------------------------------- /keyboard-control/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Launch Program", 11 | "skipFiles": [ 12 | "/**" 13 | ], 14 | "console": "integratedTerminal", 15 | "program": "${workspaceFolder}/dist/list-test.js" 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /my-prompts/src/test2.ts: -------------------------------------------------------------------------------- 1 | import { prompt, PromptOptions } from "./index.js"; 2 | 3 | const questions: PromptOptions[] = [ 4 | { 5 | message: '你的名字?', 6 | type: 'text', 7 | name: 'name' 8 | }, 9 | { 10 | message: '年龄?', 11 | type: 'text', 12 | name: 'age' 13 | }, 14 | { 15 | message: '你的班级?', 16 | type: 'select', 17 | name: 'class', 18 | choices: [ 19 | '一班', 20 | '二班', 21 | '三班' 22 | ] 23 | } 24 | ]; 25 | 26 | (async function() { 27 | const answers = await prompt(questions); 28 | console.log(answers); 29 | })(); 30 | -------------------------------------------------------------------------------- /auto-i18n-cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "auto-i18n-cli", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "@types/babel__core": "^7.20.5", 15 | "@types/node": "^22.5.4", 16 | "typescript": "^5.5.4" 17 | }, 18 | "dependencies": { 19 | "@babel/core": "^7.25.2", 20 | "@babel/parser": "^7.25.6", 21 | "@babel/template": "^7.25.0", 22 | "@babel/types": "^7.25.6", 23 | "prettier": "^3.3.3" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /guang-cli/packages/template-vue/template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= projectName %>", 3 | "description": "脚手架创建的 <%= projectName %> 项目", 4 | "private": true, 5 | "version": "0.0.0", 6 | "type": "module", 7 | "scripts": { 8 | "dev": "vite", 9 | "build": "vue-tsc -b && vite build", 10 | "preview": "vite preview" 11 | }, 12 | "dependencies": { 13 | "vue": "^3.5.12" 14 | }, 15 | "devDependencies": { 16 | "@vitejs/plugin-vue": "^5.1.4", 17 | "typescript": "~5.6.2", 18 | "vite": "^5.4.10", 19 | "vue-tsc": "^2.1.8" 20 | }, 21 | "main": "index.js", 22 | "keywords": [], 23 | "author": "", 24 | "license": "ISC" 25 | } 26 | -------------------------------------------------------------------------------- /my-git/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Launch Program", 11 | "skipFiles": [ 12 | "/**" 13 | ], 14 | "args": [ 15 | "log" 16 | ], 17 | "program": "${workspaceFolder}/src/index.mjs" 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /blessed-contrib-test/src/line.js: -------------------------------------------------------------------------------- 1 | const blessed = require('blessed'); 2 | const contrib = require('blessed-contrib'); 3 | 4 | const screen = blessed.screen({ 5 | fullUnicode: true 6 | }); 7 | 8 | const lineChart = line = contrib.line({ 9 | style: { 10 | line: "yellow", 11 | text: "green", 12 | baseline: "blue" 13 | }, 14 | label: '气温变化', 15 | }) 16 | 17 | const data = { 18 | x: ['10 月 1 日', '10 月 2 日', '10 月 3 日', '10 月 4 日'], 19 | y: [6, 13, 8, 10] 20 | } 21 | 22 | screen.append(lineChart); 23 | lineChart.setData([data]); 24 | 25 | screen.key('C-c', function() { 26 | screen.destroy(); 27 | }); 28 | 29 | screen.render(); 30 | -------------------------------------------------------------------------------- /cli-progress-test/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Bar } from 'cli-progress'; 2 | 3 | const bar = new Bar({ 4 | format: '进度:{bar} | {percentage}% || {value}/{total} || 速度: {speed}', 5 | barCompleteChar: '\u2588', 6 | barIncompleteChar: '\u2591', 7 | hideCursor: true 8 | }); 9 | 10 | bar.start(200, 0, { 11 | speed: "0" 12 | }); 13 | 14 | let value = 0; 15 | 16 | const timer = setInterval(function(){ 17 | value++; 18 | 19 | bar.update(value, { 20 | speed: (60 * Math.random()).toFixed(2) + "Mb/s" 21 | }); 22 | 23 | if (value >= bar.getTotal()){ 24 | clearInterval(timer); 25 | 26 | bar.stop(); 27 | } 28 | }, 20); 29 | 30 | 31 | -------------------------------------------------------------------------------- /ast-transform-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ast-transform-test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "@types/babel__core": "^7.20.5", 15 | "@types/node": "^22.5.4", 16 | "typescript": "^5.5.4" 17 | }, 18 | "dependencies": { 19 | "@babel/core": "^7.25.2", 20 | "@babel/parser": "^7.25.6", 21 | "@babel/template": "^7.25.0", 22 | "@babel/types": "^7.25.6", 23 | "prettier": "^3.3.3" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /react-i18n-test/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "isolatedModules": true, 13 | "moduleDetection": "force", 14 | "noEmit": true, 15 | "jsx": "react-jsx", 16 | 17 | /* Linting */ 18 | "strict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true 22 | }, 23 | "include": ["src"] 24 | } 25 | -------------------------------------------------------------------------------- /sqlite-test/src/index3.mjs: -------------------------------------------------------------------------------- 1 | import sqlite3 from 'sqlite3'; 2 | 3 | const db = new sqlite3.Database(':memory:'); 4 | 5 | db.serialize(() => { 6 | db.run(` 7 | CREATE TABLE student( 8 | id INTEGER PRIMARY KEY, 9 | name TEXT, 10 | age INT 11 | ) STRICT 12 | `); 13 | 14 | const stmt = db.prepare('INSERT INTO student (id, name, age) VALUES (?, ?, ?)'); 15 | stmt.run(1, '张三', 20); 16 | stmt.run(2, '李四', 21); 17 | stmt.run(3, '王五', 22); 18 | stmt.finalize(); 19 | 20 | db.each('SELECT * FROM student ORDER BY id', (err, row) => { 21 | console.log(row.id, row.name, row.age); 22 | }); 23 | }); 24 | 25 | db.close(); 26 | -------------------------------------------------------------------------------- /my-create-vite/template-react-ts/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "isolatedModules": true, 13 | "moduleDetection": "force", 14 | "noEmit": true, 15 | "jsx": "react-jsx", 16 | 17 | /* Linting */ 18 | "strict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true 22 | }, 23 | "include": ["src"] 24 | } 25 | -------------------------------------------------------------------------------- /buffer-test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 24 | 25 | -------------------------------------------------------------------------------- /auto-i18n-cli/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Launch Program", 11 | "skipFiles": [ 12 | "/**" 13 | ], 14 | "program": "${workspaceFolder}/dist/test.js", 15 | "outFiles": [ 16 | "${workspaceFolder}/**/*.js" 17 | ] 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /node-api-test/fs4.mjs: -------------------------------------------------------------------------------- 1 | import fs from 'node:fs'; 2 | import path from 'node:path'; 3 | 4 | function copyDir(srcDir, destDir) { 5 | fs.mkdirSync(destDir, { recursive: true }); 6 | 7 | for (const file of fs.readdirSync(srcDir)) { 8 | const srcFile = path.resolve(srcDir, file) 9 | const destFile = path.resolve(destDir, file) 10 | copy(srcFile, destFile) 11 | } 12 | } 13 | 14 | function copy(src, dest) { 15 | const stat = fs.statSync(src) 16 | if (stat.isDirectory()) { 17 | copyDir(src, dest) 18 | } else { 19 | fs.copyFileSync(src, dest) 20 | } 21 | } 22 | 23 | copy('aaa', 'aaa2'); 24 | 25 | fs.cpSync('aaa', 'aaa3', { 26 | recursive: true 27 | }); 28 | -------------------------------------------------------------------------------- /react-comp-lib/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "declaration": true, 5 | "allowSyntheticDefaultImports": true, 6 | "target": "es2015", 7 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 8 | "module": "ESNext", 9 | "skipLibCheck": true, 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | "jsx": "react-jsx", 16 | "strict": true, 17 | }, 18 | "include": [ 19 | "src" 20 | ], 21 | "exclude": [ 22 | "src/**/*.test.tsx", 23 | "src/**/*.stories.tsx" 24 | ] 25 | } -------------------------------------------------------------------------------- /react-comp/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", 4 | "target": "ES2022", 5 | "lib": ["ES2023"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "isolatedModules": true, 13 | "moduleDetection": "force", 14 | "noEmit": true, 15 | 16 | /* Linting */ 17 | "strict": true, 18 | "noUnusedLocals": true, 19 | "noUnusedParameters": true, 20 | "noFallthroughCasesInSwitch": true, 21 | "noUncheckedSideEffectImports": true 22 | }, 23 | "include": ["vite.config.ts"] 24 | } 25 | -------------------------------------------------------------------------------- /react-i18n-test/src/App.tsx: -------------------------------------------------------------------------------- 1 | import { useState } from 'react' 2 | import './App.css' 3 | import { defineMessages, useIntl } from 'react-intl' 4 | 5 | const messsages = defineMessages({ 6 | increase: { 7 | id: "increase", 8 | }, 9 | decrease: { 10 | id: "decrease" 11 | } 12 | }) 13 | 14 | function App() { 15 | const [count, setCount] = useState(0) 16 | const intl = useIntl(); 17 | 18 | return
19 |
{count}
20 | 21 | 22 |
23 | } 24 | 25 | export default App 26 | -------------------------------------------------------------------------------- /rollup-test/webpack.config.mjs: -------------------------------------------------------------------------------- 1 | import path from 'node:path'; 2 | import MiniCssExtractPlugin from "./mini-css-extract-plugin.mjs"; 3 | 4 | /** @type {import("webpack").Configuration} */ 5 | export default { 6 | entry: './src/index.js', 7 | mode: 'development', 8 | devtool: false, 9 | output: { 10 | path: path.resolve(import.meta.dirname, 'dist2'), 11 | filename: 'bundle.js', 12 | }, 13 | module: { 14 | rules: [{ 15 | test: /\.css$/i, 16 | use: [MiniCssExtractPlugin.loader, "css-loader"], 17 | }], 18 | }, 19 | plugins: [ 20 | new MiniCssExtractPlugin({ 21 | filename: 'index.css' 22 | }) 23 | ] 24 | }; 25 | -------------------------------------------------------------------------------- /blessed-contrib-test/src/gauge.js: -------------------------------------------------------------------------------- 1 | const blessed = require('blessed'); 2 | const contrib = require('blessed-contrib'); 3 | 4 | const screen = blessed.screen({ 5 | fullUnicode: true 6 | }); 7 | 8 | const gauge = contrib.gauge({ 9 | label: '下载进度', 10 | width: 'half', 11 | stroke: 'green', 12 | fill: 'white' 13 | }); 14 | 15 | screen.append(gauge); 16 | 17 | let total = 0; 18 | const timer = setInterval(() => { 19 | if(total === 100) { 20 | clearInterval(timer); 21 | } 22 | 23 | gauge.setPercent(total) 24 | screen.render(); 25 | 26 | total += 2; 27 | }, 100); 28 | 29 | 30 | screen.key('C-c', function() { 31 | screen.destroy(); 32 | }); 33 | 34 | screen.render(); 35 | -------------------------------------------------------------------------------- /ansi-test/index5.js: -------------------------------------------------------------------------------- 1 | import chalk from 'chalk'; 2 | 3 | const log = console.log; 4 | 5 | log(chalk.blue('Hello') + ' World' + chalk.red('!')); 6 | log(chalk.blue.bgRed.bold('Hello world!')); 7 | log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz')); 8 | log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!')); 9 | log(chalk.green( 10 | 'I am a green line ' + 11 | chalk.blue.underline.bold('with a blue substring') + 12 | ' that becomes green again!' 13 | )); 14 | 15 | log(` 16 | CPU: ${chalk.red('90%')} 17 | RAM: ${chalk.green('40%')} 18 | DISK: ${chalk.yellow('70%')} 19 | `); 20 | 21 | log(chalk.rgb(123, 45, 67).underline('Underlined reddish color')); 22 | log(chalk.hex('#DEADED').bold('Bold gray!')); -------------------------------------------------------------------------------- /my-comp-lib-test/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", 4 | "target": "ES2022", 5 | "lib": ["ES2023"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "isolatedModules": true, 13 | "moduleDetection": "force", 14 | "noEmit": true, 15 | 16 | /* Linting */ 17 | "strict": true, 18 | "noUnusedLocals": true, 19 | "noUnusedParameters": true, 20 | "noFallthroughCasesInSwitch": true, 21 | "noUncheckedSideEffectImports": true 22 | }, 23 | "include": ["vite.config.ts"] 24 | } 25 | -------------------------------------------------------------------------------- /guang-cli/packages/utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@guang-cli/utils", 3 | "version": "1.1.2", 4 | "publishConfig": { 5 | "access": "public" 6 | }, 7 | "type": "module", 8 | "main": "dist/index.js", 9 | "types": "dist/index.d.ts", 10 | "scripts": { 11 | "test": "echo \"Error: no test specified\" && exit 1" 12 | }, 13 | "keywords": [], 14 | "author": "", 15 | "license": "ISC", 16 | "description": "", 17 | "dependencies": { 18 | "axios": "^1.7.7", 19 | "fs-extra": "^11.2.0", 20 | "npminstall": "^7.12.0", 21 | "semver": "^7.6.3", 22 | "url-join": "^5.0.0" 23 | }, 24 | "devDependencies": { 25 | "@types/fs-extra": "^11.0.4", 26 | "@types/semver": "^7.5.8" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /my-create-vite/template-vue-ts/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "module": "ESNext", 6 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "isolatedModules": true, 13 | "moduleDetection": "force", 14 | "noEmit": true, 15 | "jsx": "preserve", 16 | 17 | /* Linting */ 18 | "strict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true 22 | }, 23 | "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"] 24 | } 25 | -------------------------------------------------------------------------------- /stream-test/src/transform.mjs: -------------------------------------------------------------------------------- 1 | import { Transform } from 'node:stream'; 2 | 3 | class ReverseStream extends Transform { 4 | 5 | _transform(buf, enc, next) { 6 | const res = buf.toString().split('').reverse().join(''); 7 | this.push(res); 8 | 9 | next() 10 | } 11 | } 12 | 13 | var transformStream = new ReverseStream(); 14 | 15 | transformStream.on('data', data => console.log(data.toString())) 16 | transformStream.on('end', data => console.log('read done')); 17 | 18 | transformStream.write('阿门阿前一棵葡萄树'); 19 | transformStream.write('阿东阿东绿的刚发芽'); 20 | transformStream.write('阿东背着那重重的的壳呀'); 21 | transformStream.write('一步一步地往上爬'); 22 | transformStream.end() 23 | 24 | transformStream.on('finish', data => console.log('write done')); -------------------------------------------------------------------------------- /guang-cli/packages/generate/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@guang-cli/generate", 3 | "version": "1.2.0", 4 | "publishConfig": { 5 | "access": "public" 6 | }, 7 | "type": "module", 8 | "main": "dist/index.js", 9 | "types": "dist/index.d.ts", 10 | "scripts": { 11 | "test": "echo \"Error: no test specified\" && exit 1" 12 | }, 13 | "keywords": [], 14 | "author": "", 15 | "license": "ISC", 16 | "description": "", 17 | "dependencies": { 18 | "@inquirer/prompts": "^7.1.0", 19 | "cosmiconfig": "^9.0.0", 20 | "fs-extra": "^11.2.0", 21 | "openai": "^4.73.0", 22 | "ora": "^8.1.1", 23 | "remark": "^15.0.1" 24 | }, 25 | "devDependencies": { 26 | "@types/fs-extra": "^11.0.4" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /exceljs-test/index.js: -------------------------------------------------------------------------------- 1 | const { Workbook } = require('exceljs'); 2 | 3 | async function main(){ 4 | const workbook = new Workbook(); 5 | 6 | const workbook2 = await workbook.xlsx.readFile('./data.xlsx'); 7 | 8 | workbook2.eachSheet((sheet, index1) => { 9 | console.log('工作表' + index1); 10 | 11 | const value = sheet.getSheetValues(); 12 | 13 | console.log(value); 14 | 15 | // sheet.eachRow((row, index2) => { 16 | // const rowData = []; 17 | 18 | // row.eachCell((cell, index3) => { 19 | // rowData.push(cell.value); 20 | // }); 21 | 22 | // console.log('行' + index2, rowData); 23 | // }) 24 | }) 25 | 26 | } 27 | 28 | main(); 29 | -------------------------------------------------------------------------------- /guang-cli/packages/template-vue/template/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", 4 | "target": "ES2022", 5 | "lib": ["ES2023"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "Bundler", 11 | "allowImportingTsExtensions": true, 12 | "isolatedModules": true, 13 | "moduleDetection": "force", 14 | "noEmit": true, 15 | 16 | /* Linting */ 17 | "strict": true, 18 | "noUnusedLocals": true, 19 | "noUnusedParameters": true, 20 | "noFallthroughCasesInSwitch": true, 21 | "noUncheckedSideEffectImports": true 22 | }, 23 | "include": ["vite.config.ts"] 24 | } 25 | -------------------------------------------------------------------------------- /guang-cli/packages/template-react/template/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", 4 | "target": "ES2022", 5 | "lib": ["ES2023"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "Bundler", 11 | "allowImportingTsExtensions": true, 12 | "isolatedModules": true, 13 | "moduleDetection": "force", 14 | "noEmit": true, 15 | 16 | /* Linting */ 17 | "strict": true, 18 | "noUnusedLocals": true, 19 | "noUnusedParameters": true, 20 | "noFallthroughCasesInSwitch": true, 21 | "noUncheckedSideEffectImports": true 22 | }, 23 | "include": ["vite.config.ts"] 24 | } 25 | -------------------------------------------------------------------------------- /node-api-test/cluster.mjs: -------------------------------------------------------------------------------- 1 | import cluster from 'node:cluster'; 2 | import http from 'node:http'; 3 | import { cpus } from 'node:os'; 4 | 5 | const numCPUs = cpus().length; 6 | 7 | if (cluster.isPrimary) { 8 | for (let i = 0; i < numCPUs; i++) { 9 | cluster.fork(); 10 | } 11 | 12 | cluster.on('fork', (worker) => { 13 | console.log('worker 创建成功', worker.id); 14 | }); 15 | 16 | cluster.on('exit', (worker, code, signal) => { 17 | console.log('worker 退出:', worker.id); 18 | }); 19 | } else { 20 | const server = http.createServer((req, res) => { 21 | res.writeHead(200); 22 | res.end('hello world\n'); 23 | }) 24 | 25 | server.listen(8000); 26 | 27 | setTimeout(()=> { 28 | process.exit(); 29 | }, 3000) 30 | } 31 | -------------------------------------------------------------------------------- /guang-cli/packages/cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@guang-cli/cli", 3 | "version": "0.1.0", 4 | "publishConfig": { 5 | "access": "public" 6 | }, 7 | "type": "module", 8 | "main": "dist/index.js", 9 | "types": "dist/index.d.ts", 10 | "bin": { 11 | "guang-ci": "./dist/index.js" 12 | }, 13 | "scripts": { 14 | "test": "echo \"Error: no test specified\" && exit 1" 15 | }, 16 | "keywords": [], 17 | "author": "", 18 | "license": "ISC", 19 | "description": "", 20 | "dependencies": { 21 | "@guang-cli/create": "workspace:^", 22 | "@guang-cli/generate": "workspace:^", 23 | "commander": "^12.1.0", 24 | "fs-extra": "^11.2.0" 25 | }, 26 | "devDependencies": { 27 | "@types/fs-extra": "^11.0.4" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /rollup-test/my-extract-css-rollup-plugin.mjs: -------------------------------------------------------------------------------- 1 | const extractArr = []; 2 | 3 | export default function myExtractCssRollupPlugin (opts) { 4 | return { 5 | name: 'my-extract-css-rollup-plugin', 6 | transform(code, id) { 7 | if(!id.endsWith('.css')) { 8 | return null; 9 | } 10 | 11 | extractArr.push(code); 12 | 13 | return { 14 | code: 'export default "神说要有光"', 15 | map: { mappings: '' } 16 | } 17 | }, 18 | generateBundle(options, bundle) { 19 | 20 | this.emitFile({ 21 | fileName: opts.filename || 'guang.css', 22 | type: 'asset', 23 | source: extractArr.join('\n/*光光666*/\n') 24 | }) 25 | } 26 | }; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /guang-cli/packages/create/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@guang-cli/create", 3 | "version": "0.3.1", 4 | "publishConfig": { 5 | "access": "public" 6 | }, 7 | "type": "module", 8 | "main": "dist/index.js", 9 | "types": "dist/index.d.ts", 10 | "scripts": { 11 | "test": "echo \"Error: no test specified\" && exit 1" 12 | }, 13 | "keywords": [], 14 | "author": "", 15 | "license": "ISC", 16 | "description": "", 17 | "dependencies": { 18 | "@guang-cli/utils": "workspace:^", 19 | "@inquirer/prompts": "^7.1.0", 20 | "ejs": "^3.1.10", 21 | "fs-extra": "^11.2.0", 22 | "glob": "^11.0.0", 23 | "ora": "^8.1.1" 24 | }, 25 | "devDependencies": { 26 | "@types/ejs": "^3.1.5", 27 | "@types/fs-extra": "^11.0.4" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /react-comp/src/Button/index.tsx: -------------------------------------------------------------------------------- 1 | import { CSSProperties, MouseEventHandler, PropsWithChildren } from 'react' 2 | import './index.scss'; 3 | 4 | export interface ButtonProps extends PropsWithChildren { 5 | className?: string; 6 | style?: CSSProperties; 7 | type?: 'primary' | 'default'; 8 | onClick?: MouseEventHandler 9 | } 10 | 11 | function Button(props: ButtonProps) { 12 | const { 13 | className = '', 14 | style, 15 | type = 'primary', 16 | children, 17 | onClick = () => {} 18 | } = props 19 | 20 | return
{children}
25 | } 26 | 27 | export default Button; 28 | 29 | 30 | -------------------------------------------------------------------------------- /stream-test/src/writable.mjs: -------------------------------------------------------------------------------- 1 | import { Writable } from 'node:stream'; 2 | 3 | class WritableDong extends Writable { 4 | 5 | constructor(iterator) { 6 | super(); 7 | this.iterator = iterator; 8 | } 9 | 10 | _write(data, enc, next) { 11 | console.log(data.toString()); 12 | setTimeout(() => { 13 | next(); 14 | }, 1000); 15 | } 16 | } 17 | 18 | function createWriteStream() { 19 | return new WritableDong(); 20 | } 21 | 22 | const writeStream = createWriteStream(); 23 | 24 | writeStream.on('finish', () => console.log('done')); 25 | 26 | writeStream.write('阿门阿前一棵葡萄树,'); 27 | writeStream.write('阿东阿东绿的刚发芽,'); 28 | writeStream.write('阿东背着那重重的的壳呀,'); 29 | writeStream.write('一步一步地往上爬。'); 30 | writeStream.end(); 31 | -------------------------------------------------------------------------------- /react-comp-lib/src/Button/index.tsx: -------------------------------------------------------------------------------- 1 | import { CSSProperties, MouseEventHandler, PropsWithChildren } from 'react' 2 | import './index.scss'; 3 | 4 | export interface ButtonProps extends PropsWithChildren { 5 | className?: string; 6 | style?: CSSProperties; 7 | type?: 'primary' | 'default'; 8 | onClick?: MouseEventHandler 9 | } 10 | 11 | function Button(props: ButtonProps) { 12 | const { 13 | className = '', 14 | style, 15 | type = 'primary', 16 | children, 17 | onClick = () => {} 18 | } = props 19 | 20 | return
{children}
25 | } 26 | 27 | export default Button; 28 | 29 | 30 | -------------------------------------------------------------------------------- /pnpm-monorepo-test/packages/cli/src/index.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import { Command } from 'commander'; 3 | import chalk from "chalk"; 4 | import { add, minus } from '@guang-pnpm/core'; 5 | 6 | const program = new Command(); 7 | 8 | program 9 | .name('num cli') 10 | .description('计算数字加减') 11 | .version('0.0.1'); 12 | 13 | program.command('add') 14 | .description('加法') 15 | .argument('a', '第一个数字') 16 | .argument('b', '第二个数字') 17 | .action((a: string, b: string) => { 18 | console.log(chalk.green(add(+a, +b))) 19 | }); 20 | 21 | program.command('minus') 22 | .description('减法') 23 | .argument('a', '第一个数字') 24 | .argument('b', '第二个数字') 25 | .action((a: string, b: string) => { 26 | console.log(chalk.cyan(minus(+a, +b))) 27 | }); 28 | 29 | program.parse(); 30 | -------------------------------------------------------------------------------- /worker-test/page/index2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | worker performance optimization 6 | 7 | 8 | 24 | 25 | -------------------------------------------------------------------------------- /blessed-test/src/progressbar.js: -------------------------------------------------------------------------------- 1 | const blessed = require('blessed'); 2 | 3 | const screen = blessed.screen({ 4 | fullUnicode: true 5 | }); 6 | 7 | const progressBar = blessed.progressbar({ 8 | parent: screen, 9 | top: '50%', 10 | left: '50%', 11 | height: 2, 12 | width: 20, 13 | style: { 14 | bg: 'gray', 15 | bar: { 16 | bg: 'green' 17 | } 18 | } 19 | }) 20 | 21 | screen.key('C-c', function() { 22 | screen.destroy(); 23 | }); 24 | 25 | let total = 0; 26 | const timer = setInterval(() => { 27 | if(total === 100) { 28 | clearInterval(timer); 29 | } 30 | 31 | progressBar.setProgress(total) 32 | screen.render(); 33 | 34 | total += 2; 35 | }, 100); 36 | 37 | screen.render(); 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /my-git/src/init.mjs: -------------------------------------------------------------------------------- 1 | import fs from 'node:fs'; 2 | 3 | export function init() { 4 | const projectDir = process.cwd(); 5 | 6 | const isExist = fs.existsSync(`${projectDir}/.my-git`); 7 | 8 | if(isExist) { 9 | console.log('Your project has been Initialized.'); 10 | return; 11 | } 12 | 13 | [ 14 | `${projectDir}/.my-git`, 15 | `${projectDir}/.my-git/objects`, 16 | `${projectDir}/.my-git/refs`, 17 | `${projectDir}/.my-git/refs/heads` 18 | ].forEach(dir => { 19 | fs.mkdirSync(dir, { 20 | recursive: true 21 | }); 22 | }) 23 | 24 | fs.writeFileSync(`${projectDir}/.my-git/HEAD`, 'ref: refs/heads/main'); 25 | 26 | console.log(`Initialized empty my-git repository in ${projectDir}`); 27 | } 28 | -------------------------------------------------------------------------------- /cli-progress-test/src/test.ts: -------------------------------------------------------------------------------- 1 | import ansiEscapes from 'ansi-escapes'; 2 | 3 | process.stdout.write(ansiEscapes.cursorHide) 4 | process.stdout.write(ansiEscapes.cursorSavePosition) 5 | process.stdout.write('░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░'); 6 | 7 | 8 | setTimeout(() => { 9 | process.stdout.write(ansiEscapes.cursorRestorePosition) 10 | process.stdout.write('████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░'); 11 | }, 1000) 12 | 13 | setTimeout(() => { 14 | process.stdout.write(ansiEscapes.cursorRestorePosition) 15 | process.stdout.write('███████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░'); 16 | }, 2000) 17 | 18 | setTimeout(() => { 19 | process.stdout.write(ansiEscapes.cursorRestorePosition) 20 | process.stdout.write('██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░'); 21 | }, 3000) 22 | 23 | -------------------------------------------------------------------------------- /guang-cli/packages/cli/src/index.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import create from '@guang-cli/create'; 3 | import generate from '@guang-cli/generate'; 4 | import { Command } from 'commander'; 5 | import fse from 'fs-extra'; 6 | import path from 'node:path'; 7 | 8 | const pkgJson = fse.readJSONSync(path.join(import.meta.dirname, '../package.json')); 9 | 10 | const program = new Command(); 11 | 12 | program 13 | .name('guang-cli') 14 | .description('脚手架 cli') 15 | .version(pkgJson.version); 16 | 17 | program.command('create') 18 | .description('创建项目') 19 | .action(async () => { 20 | create(); 21 | }); 22 | 23 | program.command('generate') 24 | .description('生成组件(基于 AI)') 25 | .action(async () => { 26 | generate(); 27 | }); 28 | 29 | program.parse(); 30 | -------------------------------------------------------------------------------- /my-create-vite/template-vue/src/App.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 16 | 17 | 31 | -------------------------------------------------------------------------------- /react-comp/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", 4 | "target": "ES2020", 5 | "useDefineForClassFields": true, 6 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 7 | "module": "ESNext", 8 | "skipLibCheck": true, 9 | 10 | /* Bundler mode */ 11 | "moduleResolution": "bundler", 12 | "allowImportingTsExtensions": true, 13 | "isolatedModules": true, 14 | "moduleDetection": "force", 15 | "noEmit": true, 16 | "jsx": "react-jsx", 17 | 18 | /* Linting */ 19 | "strict": true, 20 | "noUnusedLocals": true, 21 | "noUnusedParameters": true, 22 | "noFallthroughCasesInSwitch": true, 23 | "noUncheckedSideEffectImports": true 24 | }, 25 | "include": ["src"] 26 | } 27 | -------------------------------------------------------------------------------- /guang-cli/packages/utils/src/test.ts: -------------------------------------------------------------------------------- 1 | import NpmPackage from './NpmPackage.js'; 2 | import { getLatestVersion, getNpmInfo, getNpmRegistry, getVersions } from './versionUtils.js'; 3 | import path from 'node:path'; 4 | 5 | async function main() { 6 | // const version = await getLatestVersion('create-vite'); 7 | 8 | // console.log(version); 9 | 10 | // const versions = await getVersions('create-vite'); 11 | 12 | // console.log(versions); 13 | 14 | const pkg = new NpmPackage({ 15 | targetPath: path.join(import.meta.dirname, '../aaa'), 16 | name: '@babel/core' 17 | }); 18 | 19 | if(await pkg.exists()) { 20 | pkg.update(); 21 | } else { 22 | pkg.install(); 23 | } 24 | 25 | console.log(await pkg.getPackageJSON()) 26 | } 27 | 28 | main(); 29 | -------------------------------------------------------------------------------- /my-comp-lib-test/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", 4 | "target": "ES2020", 5 | "useDefineForClassFields": true, 6 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 7 | "module": "ESNext", 8 | "skipLibCheck": true, 9 | 10 | /* Bundler mode */ 11 | "moduleResolution": "bundler", 12 | "allowImportingTsExtensions": true, 13 | "isolatedModules": true, 14 | "moduleDetection": "force", 15 | "noEmit": true, 16 | "jsx": "react-jsx", 17 | 18 | /* Linting */ 19 | "strict": true, 20 | "noUnusedLocals": true, 21 | "noUnusedParameters": true, 22 | "noFallthroughCasesInSwitch": true, 23 | "noUncheckedSideEffectImports": true 24 | }, 25 | "include": ["src"] 26 | } 27 | -------------------------------------------------------------------------------- /blessed-test/src/filemanager.js: -------------------------------------------------------------------------------- 1 | const blessed = require('blessed'); 2 | 3 | const screen = blessed.screen({ 4 | fullUnicode: true 5 | }); 6 | 7 | const fm = blessed.filemanager({ 8 | parent: screen, 9 | border: 'line', 10 | height: 'half', 11 | width: 'half', 12 | top: 'center', 13 | left: 'center', 14 | label: ' {blue-fg}%path{/blue-fg} ', 15 | cwd: process.cwd(), 16 | keys: true, 17 | style: { 18 | selected: { 19 | bg: 'blue' 20 | } 21 | }, 22 | scrollbar: { 23 | bg: 'white' 24 | } 25 | }); 26 | 27 | fm.on('file', (file)=> { 28 | screen.destroy(); 29 | 30 | console.log(file); 31 | }) 32 | 33 | screen.key('C-c', function() { 34 | screen.destroy(); 35 | }); 36 | 37 | fm.refresh(); 38 | 39 | screen.render(); 40 | -------------------------------------------------------------------------------- /my-create-vite/template-react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vite-react-starter", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "vite build", 9 | "lint": "eslint .", 10 | "preview": "vite preview" 11 | }, 12 | "dependencies": { 13 | "react": "^18.3.1", 14 | "react-dom": "^18.3.1" 15 | }, 16 | "devDependencies": { 17 | "@eslint/js": "^9.11.1", 18 | "@types/react": "^18.3.10", 19 | "@types/react-dom": "^18.3.0", 20 | "@vitejs/plugin-react": "^4.3.2", 21 | "eslint": "^9.11.1", 22 | "eslint-plugin-react": "^7.37.0", 23 | "eslint-plugin-react-hooks": "^5.1.0-rc.0", 24 | "eslint-plugin-react-refresh": "^0.4.12", 25 | "globals": "^15.9.0", 26 | "vite": "^5.4.8" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /my-create-vite/template-vue-ts/src/App.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 16 | 17 | 31 | -------------------------------------------------------------------------------- /react-comp/src/App.css: -------------------------------------------------------------------------------- 1 | #root { 2 | max-width: 1280px; 3 | margin: 0 auto; 4 | padding: 2rem; 5 | text-align: center; 6 | } 7 | 8 | .logo { 9 | height: 6em; 10 | padding: 1.5em; 11 | will-change: filter; 12 | transition: filter 300ms; 13 | } 14 | .logo:hover { 15 | filter: drop-shadow(0 0 2em #646cffaa); 16 | } 17 | .logo.react:hover { 18 | filter: drop-shadow(0 0 2em #61dafbaa); 19 | } 20 | 21 | @keyframes logo-spin { 22 | from { 23 | transform: rotate(0deg); 24 | } 25 | to { 26 | transform: rotate(360deg); 27 | } 28 | } 29 | 30 | @media (prefers-reduced-motion: no-preference) { 31 | a:nth-of-type(2) .logo { 32 | animation: logo-spin infinite 20s linear; 33 | } 34 | } 35 | 36 | .card { 37 | padding: 2em; 38 | } 39 | 40 | .read-the-docs { 41 | color: #888; 42 | } 43 | -------------------------------------------------------------------------------- /my-comp-lib-test/src/App.css: -------------------------------------------------------------------------------- 1 | #root { 2 | max-width: 1280px; 3 | margin: 0 auto; 4 | padding: 2rem; 5 | text-align: center; 6 | } 7 | 8 | .logo { 9 | height: 6em; 10 | padding: 1.5em; 11 | will-change: filter; 12 | transition: filter 300ms; 13 | } 14 | .logo:hover { 15 | filter: drop-shadow(0 0 2em #646cffaa); 16 | } 17 | .logo.react:hover { 18 | filter: drop-shadow(0 0 2em #61dafbaa); 19 | } 20 | 21 | @keyframes logo-spin { 22 | from { 23 | transform: rotate(0deg); 24 | } 25 | to { 26 | transform: rotate(360deg); 27 | } 28 | } 29 | 30 | @media (prefers-reduced-motion: no-preference) { 31 | a:nth-of-type(2) .logo { 32 | animation: logo-spin infinite 20s linear; 33 | } 34 | } 35 | 36 | .card { 37 | padding: 2em; 38 | } 39 | 40 | .read-the-docs { 41 | color: #888; 42 | } 43 | -------------------------------------------------------------------------------- /react-i18n-test/src/App.css: -------------------------------------------------------------------------------- 1 | #root { 2 | max-width: 1280px; 3 | margin: 0 auto; 4 | padding: 2rem; 5 | text-align: center; 6 | } 7 | 8 | .logo { 9 | height: 6em; 10 | padding: 1.5em; 11 | will-change: filter; 12 | transition: filter 300ms; 13 | } 14 | .logo:hover { 15 | filter: drop-shadow(0 0 2em #646cffaa); 16 | } 17 | .logo.react:hover { 18 | filter: drop-shadow(0 0 2em #61dafbaa); 19 | } 20 | 21 | @keyframes logo-spin { 22 | from { 23 | transform: rotate(0deg); 24 | } 25 | to { 26 | transform: rotate(360deg); 27 | } 28 | } 29 | 30 | @media (prefers-reduced-motion: no-preference) { 31 | a:nth-of-type(2) .logo { 32 | animation: logo-spin infinite 20s linear; 33 | } 34 | } 35 | 36 | .card { 37 | padding: 2em; 38 | } 39 | 40 | .read-the-docs { 41 | color: #888; 42 | } 43 | -------------------------------------------------------------------------------- /guang-cli/packages/template-vue/template/src/App.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 16 | 17 | 31 | -------------------------------------------------------------------------------- /guang-cli/packages/template-react/template/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", 4 | "target": "ES2020", 5 | "useDefineForClassFields": true, 6 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 7 | "module": "ESNext", 8 | "skipLibCheck": true, 9 | 10 | /* Bundler mode */ 11 | "moduleResolution": "Bundler", 12 | "allowImportingTsExtensions": true, 13 | "isolatedModules": true, 14 | "moduleDetection": "force", 15 | "noEmit": true, 16 | "jsx": "react-jsx", 17 | 18 | /* Linting */ 19 | "strict": true, 20 | "noUnusedLocals": true, 21 | "noUnusedParameters": true, 22 | "noFallthroughCasesInSwitch": true, 23 | "noUncheckedSideEffectImports": true 24 | }, 25 | "include": ["src"] 26 | } 27 | -------------------------------------------------------------------------------- /my-create-vite/template-react/src/App.css: -------------------------------------------------------------------------------- 1 | #root { 2 | max-width: 1280px; 3 | margin: 0 auto; 4 | padding: 2rem; 5 | text-align: center; 6 | } 7 | 8 | .logo { 9 | height: 6em; 10 | padding: 1.5em; 11 | will-change: filter; 12 | transition: filter 300ms; 13 | } 14 | .logo:hover { 15 | filter: drop-shadow(0 0 2em #646cffaa); 16 | } 17 | .logo.react:hover { 18 | filter: drop-shadow(0 0 2em #61dafbaa); 19 | } 20 | 21 | @keyframes logo-spin { 22 | from { 23 | transform: rotate(0deg); 24 | } 25 | to { 26 | transform: rotate(360deg); 27 | } 28 | } 29 | 30 | @media (prefers-reduced-motion: no-preference) { 31 | a:nth-of-type(2) .logo { 32 | animation: logo-spin infinite 20s linear; 33 | } 34 | } 35 | 36 | .card { 37 | padding: 2em; 38 | } 39 | 40 | .read-the-docs { 41 | color: #888; 42 | } 43 | -------------------------------------------------------------------------------- /sqlite-test/src/index5.mjs: -------------------------------------------------------------------------------- 1 | import sqlite3 from 'sqlite3' 2 | import { open } from 'sqlite' 3 | 4 | async function main() { 5 | const db = await open({ 6 | filename: 'data.db', 7 | driver: sqlite3.Database 8 | }); 9 | 10 | const insert = await db.prepare('INSERT INTO student (id, name, age) VALUES (?, ?, ?)'); 11 | insert.run(4, '东东', 20); 12 | insert.run(5, '光光', 21); 13 | insert.finalize() 14 | 15 | const update = await db.prepare('UPDATE student SET name = ? WHERE id = ?'); 16 | update.run('张三222', 1); 17 | update.finalize(); 18 | 19 | const del = await db.prepare('DELETE FROM student WHERE id = ? '); 20 | del.run(4); 21 | del.finalize(); 22 | 23 | const allData = await db.all('SELECT * FROM student'); 24 | console.log(allData); 25 | } 26 | 27 | main(); 28 | -------------------------------------------------------------------------------- /my-create-vite/template-react-ts/src/App.css: -------------------------------------------------------------------------------- 1 | #root { 2 | max-width: 1280px; 3 | margin: 0 auto; 4 | padding: 2rem; 5 | text-align: center; 6 | } 7 | 8 | .logo { 9 | height: 6em; 10 | padding: 1.5em; 11 | will-change: filter; 12 | transition: filter 300ms; 13 | } 14 | .logo:hover { 15 | filter: drop-shadow(0 0 2em #646cffaa); 16 | } 17 | .logo.react:hover { 18 | filter: drop-shadow(0 0 2em #61dafbaa); 19 | } 20 | 21 | @keyframes logo-spin { 22 | from { 23 | transform: rotate(0deg); 24 | } 25 | to { 26 | transform: rotate(360deg); 27 | } 28 | } 29 | 30 | @media (prefers-reduced-motion: no-preference) { 31 | a:nth-of-type(2) .logo { 32 | animation: logo-spin infinite 20s linear; 33 | } 34 | } 35 | 36 | .card { 37 | padding: 2em; 38 | } 39 | 40 | .read-the-docs { 41 | color: #888; 42 | } 43 | -------------------------------------------------------------------------------- /guang-cli/packages/template-react/template/src/App.css: -------------------------------------------------------------------------------- 1 | #root { 2 | max-width: 1280px; 3 | margin: 0 auto; 4 | padding: 2rem; 5 | text-align: center; 6 | } 7 | 8 | .logo { 9 | height: 6em; 10 | padding: 1.5em; 11 | will-change: filter; 12 | transition: filter 300ms; 13 | } 14 | .logo:hover { 15 | filter: drop-shadow(0 0 2em #646cffaa); 16 | } 17 | .logo.react:hover { 18 | filter: drop-shadow(0 0 2em #61dafbaa); 19 | } 20 | 21 | @keyframes logo-spin { 22 | from { 23 | transform: rotate(0deg); 24 | } 25 | to { 26 | transform: rotate(360deg); 27 | } 28 | } 29 | 30 | @media (prefers-reduced-motion: no-preference) { 31 | a:nth-of-type(2) .logo { 32 | animation: logo-spin infinite 20s linear; 33 | } 34 | } 35 | 36 | .card { 37 | padding: 2em; 38 | } 39 | 40 | .read-the-docs { 41 | color: #888; 42 | } 43 | -------------------------------------------------------------------------------- /react-comp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-comp", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc -b && vite build", 9 | "lint": "eslint .", 10 | "preview": "vite preview" 11 | }, 12 | "dependencies": { 13 | "react": "^18.3.1", 14 | "react-dom": "^18.3.1", 15 | "sass": "^1.83.0" 16 | }, 17 | "devDependencies": { 18 | "@eslint/js": "^9.17.0", 19 | "@types/react": "^18.3.18", 20 | "@types/react-dom": "^18.3.5", 21 | "@vitejs/plugin-react": "^4.3.4", 22 | "eslint": "^9.17.0", 23 | "eslint-plugin-react-hooks": "^5.0.0", 24 | "eslint-plugin-react-refresh": "^0.4.16", 25 | "globals": "^15.14.0", 26 | "typescript": "~5.6.2", 27 | "typescript-eslint": "^8.18.2", 28 | "vite": "^6.0.5" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /guang-cli/packages/template-vue/template/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", 4 | "target": "ES2020", 5 | "useDefineForClassFields": true, 6 | "module": "ESNext", 7 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 8 | "skipLibCheck": true, 9 | 10 | /* Bundler mode */ 11 | "moduleResolution": "Bundler", 12 | "allowImportingTsExtensions": true, 13 | "isolatedModules": true, 14 | "moduleDetection": "force", 15 | "noEmit": true, 16 | "jsx": "preserve", 17 | 18 | /* Linting */ 19 | "strict": true, 20 | "noUnusedLocals": true, 21 | "noUnusedParameters": true, 22 | "noFallthroughCasesInSwitch": true, 23 | "noUncheckedSideEffectImports": true 24 | }, 25 | "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"] 26 | } 27 | -------------------------------------------------------------------------------- /react-i18n-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-i18n-test", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc -b && vite build", 9 | "lint": "eslint .", 10 | "preview": "vite preview" 11 | }, 12 | "dependencies": { 13 | "react": "^18.3.1", 14 | "react-dom": "^18.3.1", 15 | "react-intl": "^6.6.8" 16 | }, 17 | "devDependencies": { 18 | "@eslint/js": "^9.9.0", 19 | "@types/react": "^18.3.3", 20 | "@types/react-dom": "^18.3.0", 21 | "@vitejs/plugin-react": "^4.3.1", 22 | "eslint": "^9.9.0", 23 | "eslint-plugin-react-hooks": "^5.1.0-rc.0", 24 | "eslint-plugin-react-refresh": "^0.4.9", 25 | "globals": "^15.9.0", 26 | "typescript": "^5.5.3", 27 | "typescript-eslint": "^8.0.1", 28 | "vite": "^5.4.1" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /guang-cli/packages/cli/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @guang-cli/cli 2 | 3 | ## 0.1.0 4 | 5 | ### Minor Changes 6 | 7 | - generate command 8 | 9 | ### Patch Changes 10 | 11 | - Updated dependencies 12 | - @guang-cli/generate@1.2.0 13 | 14 | ## 0.0.7 15 | 16 | ### Patch Changes 17 | 18 | - @guang-cli/create@0.3.1 19 | 20 | ## 0.0.6 21 | 22 | ### Patch Changes 23 | 24 | - Updated dependencies 25 | - @guang-cli/create@0.3.0 26 | 27 | ## 0.0.5 28 | 29 | ### Patch Changes 30 | 31 | - Updated dependencies 32 | - @guang-cli/create@0.2.0 33 | 34 | ## 0.0.4 35 | 36 | ### Patch Changes 37 | 38 | - Updated dependencies 39 | - @guang-cli/create@0.1.0 40 | 41 | ## 0.0.3 42 | 43 | ### Patch Changes 44 | 45 | - @guang-cli/create@0.0.3 46 | 47 | ## 0.0.2 48 | 49 | ### Patch Changes 50 | 51 | - cli create 包初始化 52 | - Updated dependencies 53 | - @guang-cli/create@0.0.2 54 | -------------------------------------------------------------------------------- /my-create-vite/template-react-ts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vite-react-typescript-starter", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc -b && vite build", 9 | "lint": "eslint .", 10 | "preview": "vite preview" 11 | }, 12 | "dependencies": { 13 | "react": "^18.3.1", 14 | "react-dom": "^18.3.1" 15 | }, 16 | "devDependencies": { 17 | "@eslint/js": "^9.11.1", 18 | "@types/react": "^18.3.10", 19 | "@types/react-dom": "^18.3.0", 20 | "@vitejs/plugin-react": "^4.3.2", 21 | "eslint": "^9.11.1", 22 | "eslint-plugin-react-hooks": "^5.1.0-rc.0", 23 | "eslint-plugin-react-refresh": "^0.4.12", 24 | "globals": "^15.9.0", 25 | "typescript": "^5.5.3", 26 | "typescript-eslint": "^8.7.0", 27 | "vite": "^5.4.8" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /react-comp/eslint.config.js: -------------------------------------------------------------------------------- 1 | import js from '@eslint/js' 2 | import globals from 'globals' 3 | import reactHooks from 'eslint-plugin-react-hooks' 4 | import reactRefresh from 'eslint-plugin-react-refresh' 5 | import tseslint from 'typescript-eslint' 6 | 7 | export default tseslint.config( 8 | { ignores: ['dist'] }, 9 | { 10 | extends: [js.configs.recommended, ...tseslint.configs.recommended], 11 | files: ['**/*.{ts,tsx}'], 12 | languageOptions: { 13 | ecmaVersion: 2020, 14 | globals: globals.browser, 15 | }, 16 | plugins: { 17 | 'react-hooks': reactHooks, 18 | 'react-refresh': reactRefresh, 19 | }, 20 | rules: { 21 | ...reactHooks.configs.recommended.rules, 22 | 'react-refresh/only-export-components': [ 23 | 'warn', 24 | { allowConstantExport: true }, 25 | ], 26 | }, 27 | }, 28 | ) 29 | -------------------------------------------------------------------------------- /my-comp-lib-test/eslint.config.js: -------------------------------------------------------------------------------- 1 | import js from '@eslint/js' 2 | import globals from 'globals' 3 | import reactHooks from 'eslint-plugin-react-hooks' 4 | import reactRefresh from 'eslint-plugin-react-refresh' 5 | import tseslint from 'typescript-eslint' 6 | 7 | export default tseslint.config( 8 | { ignores: ['dist'] }, 9 | { 10 | extends: [js.configs.recommended, ...tseslint.configs.recommended], 11 | files: ['**/*.{ts,tsx}'], 12 | languageOptions: { 13 | ecmaVersion: 2020, 14 | globals: globals.browser, 15 | }, 16 | plugins: { 17 | 'react-hooks': reactHooks, 18 | 'react-refresh': reactRefresh, 19 | }, 20 | rules: { 21 | ...reactHooks.configs.recommended.rules, 22 | 'react-refresh/only-export-components': [ 23 | 'warn', 24 | { allowConstantExport: true }, 25 | ], 26 | }, 27 | }, 28 | ) 29 | -------------------------------------------------------------------------------- /react-i18n-test/eslint.config.js: -------------------------------------------------------------------------------- 1 | import js from '@eslint/js' 2 | import globals from 'globals' 3 | import reactHooks from 'eslint-plugin-react-hooks' 4 | import reactRefresh from 'eslint-plugin-react-refresh' 5 | import tseslint from 'typescript-eslint' 6 | 7 | export default tseslint.config( 8 | { ignores: ['dist'] }, 9 | { 10 | extends: [js.configs.recommended, ...tseslint.configs.recommended], 11 | files: ['**/*.{ts,tsx}'], 12 | languageOptions: { 13 | ecmaVersion: 2020, 14 | globals: globals.browser, 15 | }, 16 | plugins: { 17 | 'react-hooks': reactHooks, 18 | 'react-refresh': reactRefresh, 19 | }, 20 | rules: { 21 | ...reactHooks.configs.recommended.rules, 22 | 'react-refresh/only-export-components': [ 23 | 'warn', 24 | { allowConstantExport: true }, 25 | ], 26 | }, 27 | }, 28 | ) 29 | -------------------------------------------------------------------------------- /my-comp-lib-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-comp-lib-test", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc -b && vite build", 9 | "lint": "eslint .", 10 | "preview": "vite preview" 11 | }, 12 | "dependencies": { 13 | "@guang-comp/react-comp-lib": "^1.0.0", 14 | "react": "^18.3.1", 15 | "react-dom": "^18.3.1" 16 | }, 17 | "devDependencies": { 18 | "@eslint/js": "^9.17.0", 19 | "@types/react": "^18.3.18", 20 | "@types/react-dom": "^18.3.5", 21 | "@vitejs/plugin-react": "^4.3.4", 22 | "eslint": "^9.17.0", 23 | "eslint-plugin-react-hooks": "^5.0.0", 24 | "eslint-plugin-react-refresh": "^0.4.16", 25 | "globals": "^15.14.0", 26 | "typescript": "~5.6.2", 27 | "typescript-eslint": "^8.18.2", 28 | "vite": "^6.0.5" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /excel-export/index.js: -------------------------------------------------------------------------------- 1 | const { Workbook } = require('exceljs'); 2 | 3 | async function main(){ 4 | const workbook = new Workbook(); 5 | 6 | const worksheet = workbook.addWorksheet('guang111'); 7 | 8 | worksheet.columns = [ 9 | { header: 'ID', key: 'id', width: 20 }, 10 | { header: '姓名', key: 'name', width: 30 }, 11 | { header: '出生日期', key: 'birthday', width: 30}, 12 | { header: '手机号', key: 'phone', width: 50 } 13 | ]; 14 | 15 | const data = [ 16 | { id: 1, name: '光光', birthday: new Date('1994-07-07'), phone: '13255555555' }, 17 | { id: 2, name: '东东', birthday: new Date('1994-04-14'), phone: '13222222222' }, 18 | { id: 3, name: '小刚', birthday: new Date('1995-08-08'), phone: '13211111111' } 19 | ] 20 | worksheet.addRows(data); 21 | 22 | workbook.xlsx.writeFile('./data.xlsx'); 23 | } 24 | 25 | main(); 26 | -------------------------------------------------------------------------------- /rollup-test/rollup.config.mjs: -------------------------------------------------------------------------------- 1 | import postcss from 'rollup-plugin-postcss'; 2 | import myExtractCssRollupPlugin from './my-extract-css-rollup-plugin.mjs'; 3 | 4 | /** @type {import("rollup").RollupOptions} */ 5 | export default { 6 | input: 'src/index.js', 7 | output: [ 8 | { 9 | file: 'dist/esm.js', 10 | format: 'esm' 11 | }, 12 | { 13 | file: 'dist/cjs.js', 14 | format: "cjs" 15 | }, 16 | { 17 | file: 'dist/umd.js', 18 | name: 'Guang', 19 | format: "umd" 20 | } 21 | ], 22 | treeshake: false, 23 | plugins: [ 24 | myExtractCssRollupPlugin({ 25 | filename: '666.css' 26 | }) 27 | // postcss({ 28 | // // extract: true, 29 | // // extract: 'index.css' 30 | // }), 31 | ] 32 | }; 33 | -------------------------------------------------------------------------------- /my-create-vite/template-react-ts/eslint.config.js: -------------------------------------------------------------------------------- 1 | import js from '@eslint/js' 2 | import globals from 'globals' 3 | import reactHooks from 'eslint-plugin-react-hooks' 4 | import reactRefresh from 'eslint-plugin-react-refresh' 5 | import tseslint from 'typescript-eslint' 6 | 7 | export default tseslint.config( 8 | { ignores: ['dist'] }, 9 | { 10 | extends: [js.configs.recommended, ...tseslint.configs.recommended], 11 | files: ['**/*.{ts,tsx}'], 12 | languageOptions: { 13 | ecmaVersion: 2020, 14 | globals: globals.browser, 15 | }, 16 | plugins: { 17 | 'react-hooks': reactHooks, 18 | 'react-refresh': reactRefresh, 19 | }, 20 | rules: { 21 | ...reactHooks.configs.recommended.rules, 22 | 'react-refresh/only-export-components': [ 23 | 'warn', 24 | { allowConstantExport: true }, 25 | ], 26 | }, 27 | }, 28 | ) 29 | -------------------------------------------------------------------------------- /guang-cli/packages/template-react/template/eslint.config.js: -------------------------------------------------------------------------------- 1 | import js from '@eslint/js' 2 | import globals from 'globals' 3 | import reactHooks from 'eslint-plugin-react-hooks' 4 | import reactRefresh from 'eslint-plugin-react-refresh' 5 | import tseslint from 'typescript-eslint' 6 | 7 | export default tseslint.config( 8 | { ignores: ['dist'] }, 9 | { 10 | extends: [js.configs.recommended, ...tseslint.configs.recommended], 11 | files: ['**/*.{ts,tsx}'], 12 | languageOptions: { 13 | ecmaVersion: 2020, 14 | globals: globals.browser, 15 | }, 16 | plugins: { 17 | 'react-hooks': reactHooks, 18 | 'react-refresh': reactRefresh, 19 | }, 20 | rules: { 21 | ...reactHooks.configs.recommended.rules, 22 | 'react-refresh/only-export-components': [ 23 | 'warn', 24 | { allowConstantExport: true }, 25 | ], 26 | }, 27 | }, 28 | ) 29 | -------------------------------------------------------------------------------- /my-nest-cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-nest-cli", 3 | "version": "1.0.1", 4 | "description": "", 5 | "main": "dist/transform.js", 6 | "module": "dist/transform.js", 7 | "type": "module", 8 | "bin": { 9 | "my-cli": "./dist/cli.js" 10 | }, 11 | "files": [ 12 | "dist", 13 | "package.json", 14 | "README.md" 15 | ], 16 | "scripts": { 17 | "test": "echo \"Error: no test specified\" && exit 1" 18 | }, 19 | "keywords": [], 20 | "author": "", 21 | "license": "ISC", 22 | "devDependencies": { 23 | "@types/babel__core": "^7.20.5", 24 | "@types/node": "^22.5.4", 25 | "typescript": "^5.5.4" 26 | }, 27 | "dependencies": { 28 | "@babel/core": "^7.25.2", 29 | "@babel/parser": "^7.25.6", 30 | "@babel/template": "^7.25.0", 31 | "@babel/types": "^7.25.6", 32 | "chalk": "^5.3.0", 33 | "commander": "^12.1.0", 34 | "prettier": "^3.3.3" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /blessed-contrib-test/src/grid.js: -------------------------------------------------------------------------------- 1 | const blessed = require('blessed'); 2 | const contrib = require('blessed-contrib'); 3 | 4 | const screen = blessed.screen({ 5 | fullUnicode: true 6 | }); 7 | 8 | const grid = new contrib.grid({rows: 12, cols: 12, screen: screen}); 9 | 10 | //grid.set(row, col, rowSpan, colSpan, obj, opts) 11 | const gauge = grid.set(0, 0, 6, 6, contrib.gauge, { 12 | label: '下载进度', 13 | width: 'half', 14 | stroke: 'green', 15 | fill: 'white', 16 | percent: 0.3 17 | }) 18 | 19 | const donut = grid.set(6, 6, 6, 6, contrib.donut, { 20 | label: '进度', 21 | radius: 10, 22 | arcWidth: 2, 23 | remainColor: 'black', 24 | data: [ 25 | { percent: 0.3, label: 'aaa 进度', color: 'green' }, 26 | { percent: 0.5, label: 'bbb 进度', color: 'red' }, 27 | ] 28 | }) 29 | 30 | screen.key('C-c', function() { 31 | screen.destroy(); 32 | }); 33 | 34 | screen.render(); 35 | 36 | 37 | -------------------------------------------------------------------------------- /blessed-contrib-test/src/line2.js: -------------------------------------------------------------------------------- 1 | const blessed = require('blessed'); 2 | const contrib = require('blessed-contrib'); 3 | 4 | const screen = blessed.screen({ 5 | fullUnicode: true 6 | }); 7 | 8 | const lineChart = line = contrib.line({ 9 | style: { 10 | line: "yellow", 11 | text: "green", 12 | baseline: "blue" 13 | }, 14 | showLegend: true, 15 | label: '气温变化', 16 | }) 17 | 18 | const data1 = { 19 | title: '北京', 20 | x: ['10 月 1 日', '10 月 2 日', '10 月 3 日', '10 月 4 日'], 21 | y: [4, 10, 3, 5], 22 | style: { 23 | line: 'red' 24 | } 25 | } 26 | const data2 = { 27 | title: '上海', 28 | color: 'red', 29 | x: ['10 月 1 日', '10 月 2 日', '10 月 3 日', '10 月 4 日'], 30 | y: [6, 13, 8, 10] 31 | } 32 | 33 | screen.append(lineChart); 34 | lineChart.setData([data1, data2]); 35 | 36 | screen.key('C-c', function() { 37 | screen.destroy(); 38 | }); 39 | 40 | screen.render(); 41 | -------------------------------------------------------------------------------- /my-git/src/cat-file.mjs: -------------------------------------------------------------------------------- 1 | import fs from 'node:fs'; 2 | import zlib from 'node:zlib'; 3 | 4 | export function catFile(hash, options) { 5 | const dir = hash.slice(0, 2); 6 | const filename = hash.slice(2); 7 | 8 | const filePath = `${process.cwd()}/.my-git/objects/${dir}/${filename}`; 9 | 10 | const compressedContent = fs.readFileSync(filePath); 11 | const content = zlib.gunzipSync(compressedContent); 12 | 13 | const obj = JSON.parse(content); 14 | 15 | if(options.t) { 16 | console.log(obj.type); 17 | } else { 18 | switch(obj.type) { 19 | case 'blob': 20 | console.log(Buffer.from(obj.content.data).toString('utf-8')) 21 | break; 22 | case 'tree': 23 | console.log(obj.metadata); 24 | break; 25 | case 'commit': 26 | console.log(obj.tree); 27 | break; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /keyboard-control/src/base-ui.ts: -------------------------------------------------------------------------------- 1 | import ansiEscapes from 'ansi-escapes'; 2 | 3 | export interface Position { 4 | x: number; 5 | y: number; 6 | } 7 | 8 | export abstract class BaseUi { 9 | private readonly stdout: NodeJS.WriteStream = process.stdout; 10 | 11 | protected print(text: string) { 12 | process.stdout.write.bind(process.stdout)(text); 13 | } 14 | 15 | protected setCursorAt({ x, y }: Position) { 16 | this.print(ansiEscapes.cursorTo(x, y)); 17 | } 18 | 19 | protected printAt(message: string, position: Position) { 20 | this.setCursorAt(position); 21 | this.print(message); 22 | } 23 | 24 | protected clearLine(row: number) { 25 | this.printAt(ansiEscapes.eraseLine, { x: 0, y: row }); 26 | } 27 | 28 | get terminalSize(): { columns: number; rows: number } { 29 | return { 30 | columns: this.stdout.columns, 31 | rows: this.stdout.rows, 32 | }; 33 | } 34 | 35 | abstract render(): void; 36 | } 37 | -------------------------------------------------------------------------------- /my-comp-lib-test/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /stream-test/src/duplex.mjs: -------------------------------------------------------------------------------- 1 | import { Duplex } from 'node:stream'; 2 | 3 | class DuplexStream extends Duplex { 4 | 5 | _read() { 6 | this.push('阿门阿前一棵葡萄树,'); 7 | this.push('阿东阿东绿的刚发芽,'); 8 | this.push('阿东背着那重重的的壳呀,'); 9 | this.push('一步一步地往上爬。') 10 | this.push(null); 11 | } 12 | 13 | _write(data, enc, next) { 14 | console.log(data.toString()); 15 | setTimeout(() => { 16 | next(); 17 | }, 1000); 18 | } 19 | } 20 | 21 | const duplexStream = new DuplexStream(); 22 | 23 | duplexStream.on('data', data => { 24 | console.log(data.toString()) 25 | }); 26 | duplexStream.on('end', data => { 27 | console.log('read done') 28 | }); 29 | 30 | duplexStream.write('阿门阿前一棵葡萄树,'); 31 | duplexStream.write('阿东阿东绿的刚发芽,'); 32 | duplexStream.write('阿东背着那重重的的壳呀,'); 33 | duplexStream.write('一步一步地往上爬。'); 34 | duplexStream.end(); 35 | 36 | duplexStream.on('finish', data => { 37 | console.log('write done') 38 | }); 39 | -------------------------------------------------------------------------------- /openai-test/src/system.md: -------------------------------------------------------------------------------- 1 | # Role: 前端工程师 2 | 3 | ## Profile 4 | 5 | - author: 神光 6 | - language: 中文 7 | - description: 你非常擅长写 React 组件 8 | 9 | ## Goals 10 | 11 | - 根据用户需求生成组件代码 12 | 13 | ## Skills 14 | 15 | - 熟练掌握 typescript 16 | 17 | - 会写高质量的 React 组件 18 | 19 | ## Constraints 20 | 21 | - 用到的组件来源于 antd 22 | 23 | - 样式用 scss 写 24 | 25 | ## Workflows 26 | 27 | 根据用户描述生成的组件,规范如下: 28 | 29 | 组件包含 4 类文件: 30 | 31 | 1、index.ts 32 | 这个文件中的内容如下: 33 | export { default as [组件名] } from './[组件名]'; 34 | export type { [组件名]Props } from './interface'; 35 | 36 | 2、interface.ts 37 | 这个文件中的内容如下,请把组件的props内容补充完整: 38 | interface [组件名]Props {} 39 | export type { [组件名]Props }; 40 | 41 | 4、[组件名].tsx 42 | 这个文件中存放组件的真正业务逻辑,不能编写内联样式,如果需要样式必须在 5、styles.ts 中编写样式再导出给本文件用 43 | 44 | 5、styles.scss 45 | 这个文件中必须用 scss 给组件写样式,导出提供给 4、[组件名].tsx 46 | 47 | ## Initialization 48 | 49 | 作为前端工程师,你知道你的[Goals],掌握技能[Skills],记住[Constraints], 与用户对话,并按照[Workflows]进行回答,提供组件生成服务 50 | 51 | -------------------------------------------------------------------------------- /stream-test/src/readable3.mjs: -------------------------------------------------------------------------------- 1 | import { Readable } from 'node:stream'; 2 | 3 | class ReadableDong extends Readable { 4 | 5 | constructor(iterator) { 6 | super(); 7 | this.iterator = iterator; 8 | } 9 | 10 | _read() { 11 | const next = this.iterator.next(); 12 | if(next.done) { 13 | return this.push(null); 14 | } else { 15 | this.push(next.value) 16 | } 17 | } 18 | 19 | } 20 | 21 | function *songGenerator() { 22 | yield '阿门阿前一棵葡萄树,'; 23 | yield '阿东阿东绿的刚发芽,'; 24 | yield '阿东背着那重重的的壳呀,'; 25 | yield '一步一步地往上爬。'; 26 | } 27 | 28 | const songIterator = songGenerator(); 29 | 30 | function createReadStream(interator) { 31 | return new ReadableDong(interator); 32 | } 33 | 34 | const readableStream = createReadStream(songIterator) 35 | 36 | readableStream.on('data', (data)=> { 37 | console.log(data.toString()) 38 | }); 39 | 40 | readableStream.on('end', () => { 41 | console.log('done'); 42 | }); -------------------------------------------------------------------------------- /guang-cli/packages/template-react/template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= projectName %>", 3 | "description": "脚手架创建的 <%= projectName %> 项目", 4 | "private": true, 5 | "version": "0.0.0", 6 | "type": "module", 7 | "scripts": { 8 | "dev": "vite", 9 | "build": "tsc -b && vite build", 10 | <% if (eslint) { %> 11 | "lint": "eslint .", 12 | <% } %> 13 | "preview": "vite preview" 14 | }, 15 | "dependencies": { 16 | "react": "^18.3.1", 17 | "react-dom": "^18.3.1" 18 | }, 19 | "devDependencies": { 20 | "@eslint/js": "^9.13.0", 21 | "@types/react": "^18.3.12", 22 | "@types/react-dom": "^18.3.1", 23 | "@vitejs/plugin-react": "^4.3.3", 24 | <% if (eslint) { %> 25 | "eslint": "^9.13.0", 26 | "eslint-plugin-react-hooks": "^5.0.0", 27 | "eslint-plugin-react-refresh": "^0.4.14", 28 | <% } %> 29 | "globals": "^15.11.0", 30 | "typescript": "~5.6.2", 31 | "typescript-eslint": "^8.11.0", 32 | "vite": "^5.4.10" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /exceljs-test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 | 11 | 31 | 32 | -------------------------------------------------------------------------------- /blessed-test/src/table.js: -------------------------------------------------------------------------------- 1 | const blessed = require('blessed'); 2 | 3 | const screen = blessed.screen({ 4 | fullUnicode: true 5 | }); 6 | 7 | const table = blessed.table({ 8 | parent: screen, 9 | width: '80%', 10 | height: 'shrink', 11 | top: 'center', 12 | left: 'center', 13 | data: null, 14 | border: 'line', 15 | align: 'center', 16 | tags: true, 17 | style: { 18 | border: { 19 | fg: 'white' 20 | }, 21 | header: { 22 | fg: 'blue', 23 | bold: true 24 | }, 25 | cell: { 26 | fg: 'green' 27 | } 28 | } 29 | }); 30 | 31 | const data = [ 32 | [ '姓名', '性别', '年龄', '电话号码' ], 33 | [ '东东', '男', '20', '13233334444' ], 34 | [ '光光', '男', '20', '13233332222' ], 35 | [ '小红', '女', '21', '13233335555' ], 36 | [ '小刚', '男', '22', '13233336666' ] 37 | ]; 38 | 39 | data[1][0] = '{red-fg}' + data[1][0] + '{/red-fg}'; 40 | 41 | table.setData(data); 42 | 43 | screen.key('C-c', function() { 44 | screen.destroy(); 45 | }); 46 | 47 | screen.render(); 48 | 49 | 50 | -------------------------------------------------------------------------------- /guang-cli/packages/utils/src/versionUtils.ts: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | import urlJoin from 'url-join'; 3 | import semver from 'semver'; 4 | 5 | function getNpmRegistry() { 6 | return 'https://registry.npmmirror.com'; 7 | } 8 | 9 | async function getNpmInfo(packageName: string) { 10 | const register = getNpmRegistry(); 11 | const url = urlJoin(register, packageName); 12 | try { 13 | const response = await axios.get(url); 14 | 15 | if (response.status === 200) { 16 | return response.data; 17 | } 18 | } catch(e) { 19 | return Promise.reject(e); 20 | } 21 | } 22 | 23 | async function getLatestVersion(packageName: string) { 24 | const data = await getNpmInfo(packageName); 25 | return data['dist-tags'].latest; 26 | } 27 | 28 | async function getVersions(packageName: string) { 29 | const data = await getNpmInfo(packageName); 30 | return Object.keys(data.versions); 31 | } 32 | 33 | export { 34 | getNpmRegistry, 35 | getNpmInfo, 36 | getLatestVersion, 37 | getVersions 38 | } 39 | -------------------------------------------------------------------------------- /excel-export/index3.js: -------------------------------------------------------------------------------- 1 | const { Workbook } = require('exceljs'); 2 | const fs = require('node:fs'); 3 | 4 | async function main(){ 5 | const workbook = new Workbook(); 6 | 7 | const workbook2 = await workbook.xlsx.readFile('./bundle.xlsx'); 8 | 9 | const zhCNBundle = {}; 10 | const enUSBundle = {}; 11 | 12 | workbook2.eachSheet((sheet) => { 13 | 14 | sheet.eachRow((row, index) => { 15 | if(index === 1) { 16 | return; 17 | } 18 | const key = row.getCell(1).value; 19 | const zhCNValue = row.getCell(2).value; 20 | const enUSValue = row.getCell(3).value; 21 | 22 | zhCNBundle[key] = zhCNValue; 23 | enUSBundle[key] = enUSValue; 24 | }) 25 | }); 26 | 27 | console.log(zhCNBundle); 28 | console.log(enUSBundle); 29 | fs.writeFileSync('zh-CN.json', JSON.stringify(zhCNBundle, null, 2)); 30 | fs.writeFileSync('en-US.json', JSON.stringify(enUSBundle, null, 2)); 31 | } 32 | 33 | main(); 34 | -------------------------------------------------------------------------------- /excel-export/index5.js: -------------------------------------------------------------------------------- 1 | const { execSync } = require('node:child_process'); 2 | const { parse } = require("csv-parse/sync"); 3 | const fs = require('node:fs'); 4 | 5 | const sheetUrl = "https://docs.google.com/spreadsheets/d/15tYKwXyhKVfe2dm2G28ESjEhd_kuo2-9VMO9HPb6Zfo"; 6 | 7 | execSync(`curl -L ${sheetUrl}/export?format=csv -o ./message2.csv`, { 8 | stdio: 'ignore' 9 | }); 10 | 11 | const input = fs.readFileSync("./message2.csv"); 12 | 13 | const data = parse(input, { columns: true }); 14 | 15 | const zhCNBundle = {}; 16 | const enUSBundle = {}; 17 | 18 | data.forEach(item => { 19 | const keys = Object.keys(item); 20 | const key = item[keys[0]]; 21 | const valueZhCN = item[keys[1]]; 22 | const valueEnUS = item[keys[2]]; 23 | 24 | zhCNBundle[key] = valueZhCN; 25 | enUSBundle[key] = valueEnUS; 26 | }) 27 | 28 | console.log(zhCNBundle); 29 | console.log(enUSBundle); 30 | 31 | fs.writeFileSync('zh-CN.json', JSON.stringify(zhCNBundle, null, 2)); 32 | fs.writeFileSync('en-US.json', JSON.stringify(enUSBundle, null, 2)); -------------------------------------------------------------------------------- /react-comp-lib/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@guang-comp/react-comp-lib", 3 | "version": "1.0.1", 4 | "description": "", 5 | "main": "dist/cjs.js", 6 | "module": "dist/esm.js", 7 | "types": "dist/index.d.ts", 8 | "unpkg": "/dist/umd.js", 9 | "files": [ 10 | "dist", 11 | "package.json", 12 | "README.md" 13 | ], 14 | "publishConfig": { 15 | "access": "public" 16 | }, 17 | "scripts": { 18 | "test": "echo \"Error: no test specified\" && exit 1" 19 | }, 20 | "keywords": [], 21 | "author": "", 22 | "license": "ISC", 23 | "dependencies": { 24 | "react": "^18.3.1", 25 | "react-dom": "^18.3.1" 26 | }, 27 | "devDependencies": { 28 | "@rollup/plugin-commonjs": "^28.0.2", 29 | "@rollup/plugin-node-resolve": "^16.0.0", 30 | "@rollup/plugin-replace": "^6.0.2", 31 | "@rollup/plugin-typescript": "^12.1.2", 32 | "@types/react-dom": "^19.0.2", 33 | "rollup": "^4.29.1", 34 | "rollup-plugin-postcss": "^4.0.2", 35 | "sass": "^1.83.0", 36 | "tslib": "^2.8.1" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /my-nest-cli/src/cli.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import { transformFile } from "./transform.js"; 3 | import { access, writeFile } from "node:fs/promises"; 4 | import path from "node:path"; 5 | import { Command } from 'commander'; 6 | import chalk from "chalk"; 7 | 8 | const program = new Command(); 9 | 10 | program 11 | .name('my-nest-cli') 12 | .description('自动添加 controller') 13 | .version('0.0.1'); 14 | 15 | program.command('transform') 16 | .description('修改 module 代码,添加 controller') 17 | .argument('path', '待转换的文件路径') 18 | .action(async (filePath: string) => { 19 | if(!filePath) { 20 | console.log(chalk.red('文件路径不能为空')) 21 | } 22 | 23 | const p = path.join(process.cwd(), filePath); 24 | 25 | try { 26 | await access(p); 27 | 28 | const formattedCode = await transformFile(filePath); 29 | writeFile(p, formattedCode); 30 | 31 | console.log(`${chalk.bgBlueBright('UPDATE')} ${filePath}`) 32 | } catch(e) { 33 | console.log(chalk.red('文件路径不存在')) 34 | } 35 | }); 36 | 37 | program.parse(); 38 | -------------------------------------------------------------------------------- /keyboard-control/src/list-test.ts: -------------------------------------------------------------------------------- 1 | import ansiEscapes from 'ansi-escapes'; 2 | import { ScrollList } from "./scroll-list.js"; 3 | import readline from 'node:readline'; 4 | 5 | readline.emitKeypressEvents(process.stdin); 6 | 7 | process.stdin.setRawMode(true); 8 | 9 | const list = new ScrollList([ 10 | "红楼梦", 11 | "西游记", 12 | "水浒传", 13 | "三国演义", 14 | "儒林外史", 15 | "金瓶梅", 16 | "聊斋志异", 17 | "白鹿原", 18 | "平凡的世界", 19 | "围城", 20 | "活着", 21 | "百年孤独", 22 | "围城", 23 | "红高粱家族", 24 | "梦里花落知多少", 25 | "倾城之恋", 26 | "悲惨世界", 27 | "哈利波特", 28 | "霍乱时期的爱情", 29 | "白夜行", 30 | "解忧杂货店", 31 | "挪威的森林", 32 | "追风筝的人", 33 | "小王子", 34 | "飘", 35 | "麦田里的守望者", 36 | "时间简史", 37 | "人类简史", 38 | "活着为了讲述", 39 | "白夜行", 40 | "百鬼夜行" 41 | ]); 42 | 43 | process.stdin.on('keypress', (str, key) => { 44 | 45 | if(key.sequence === '\u0003') { 46 | process.stdout.write(ansiEscapes.clearTerminal) 47 | process.exit(); 48 | } 49 | 50 | list.onKeyInput(key.name); 51 | }); 52 | -------------------------------------------------------------------------------- /my-create-vite/template-react/src/App.jsx: -------------------------------------------------------------------------------- 1 | import { useState } from 'react' 2 | import reactLogo from './assets/react.svg' 3 | import viteLogo from '/vite.svg' 4 | import './App.css' 5 | 6 | function App() { 7 | const [count, setCount] = useState(0) 8 | 9 | return ( 10 | <> 11 | 19 |

Vite + React

20 |
21 | 24 |

25 | Edit src/App.jsx and save to test HMR 26 |

27 |
28 |

29 | Click on the Vite and React logos to learn more 30 |

31 | 32 | ) 33 | } 34 | 35 | export default App 36 | -------------------------------------------------------------------------------- /my-create-vite/template-vue-ts/src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 36 | 37 | 42 | -------------------------------------------------------------------------------- /my-create-vite/template-vue/src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 38 | 39 | 44 | -------------------------------------------------------------------------------- /my-create-vite/template-react-ts/src/App.tsx: -------------------------------------------------------------------------------- 1 | import { useState } from 'react' 2 | import reactLogo from './assets/react.svg' 3 | import viteLogo from '/vite.svg' 4 | import './App.css' 5 | 6 | function App() { 7 | const [count, setCount] = useState(0) 8 | 9 | return ( 10 | <> 11 | 19 |

Vite + React

20 |
21 | 24 |

25 | Edit src/App.tsx and save to test HMR 26 |

27 |
28 |

29 | Click on the Vite and React logos to learn more 30 |

31 | 32 | ) 33 | } 34 | 35 | export default App 36 | -------------------------------------------------------------------------------- /guang-cli/packages/template-react/template/src/App.tsx: -------------------------------------------------------------------------------- 1 | import { useState } from 'react' 2 | import reactLogo from './assets/react.svg' 3 | import viteLogo from '/vite.svg' 4 | import './App.css' 5 | 6 | function App() { 7 | const [count, setCount] = useState(0) 8 | 9 | return ( 10 | <> 11 | 19 |

Vite + React

20 |
21 | 24 |

25 | Edit src/App.tsx and save to test HMR 26 |

27 |
28 |

29 | Click on the Vite and React logos to learn more 30 |

31 | 32 | ) 33 | } 34 | 35 | export default App 36 | -------------------------------------------------------------------------------- /guang-cli/packages/template-vue/template/src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 36 | 37 | 42 | -------------------------------------------------------------------------------- /mini-puppeteer/src/install.mjs: -------------------------------------------------------------------------------- 1 | import { downloadChromium } from './lib/Downloader.mjs'; 2 | import fs from 'node:fs'; 3 | import ProgressBar from 'progress'; 4 | import path from 'node:path'; 5 | 6 | const pkgJsonPath = path.join(import.meta.dirname, '..', 'package.json'); 7 | const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8')); 8 | const revision = pkg.puppeteer.chromium_revision; 9 | 10 | downloadChromium(revision, onProgress) 11 | .catch(error => { 12 | console.error('Download failed: ' + error.message); 13 | }); 14 | 15 | let progressBar = null; 16 | function onProgress(bytesTotal, delta) { 17 | if (!progressBar) { 18 | progressBar = new ProgressBar(`Downloading Chromium - ${toMegabytes(bytesTotal)} [:bar] :percent :etas `, { 19 | complete: '\u2588', 20 | incomplete: '\u2591', 21 | width: 20, 22 | total: bytesTotal, 23 | }); 24 | } 25 | progressBar.tick(delta); 26 | } 27 | 28 | function toMegabytes(bytes) { 29 | const mb = bytes / 1024 / 1024; 30 | return (Math.round(mb * 10) / 10) + ' Mb'; 31 | } 32 | -------------------------------------------------------------------------------- /my-prompts/src/index.ts: -------------------------------------------------------------------------------- 1 | import { SelectPrompt, SelectPromptOptions } from "./SelectPrompt.js"; 2 | import { TextPromptOptions, TextPrompt } from "./TextPrompt.js"; 3 | 4 | export type PromptOptions = TextPromptOptions | SelectPromptOptions; 5 | 6 | const map: Record = { 7 | text: TextPrompt, 8 | select: SelectPrompt 9 | } 10 | 11 | async function runPrompt(question: PromptOptions) { 12 | const promptClass = map[question.type]; 13 | 14 | if(!promptClass) { 15 | return null; 16 | } 17 | 18 | return new Promise((resolve) => { 19 | const prompt = new promptClass(question); 20 | 21 | prompt.render(); 22 | 23 | prompt.on('submit', (answer: string) => { 24 | resolve(answer) 25 | }) 26 | }); 27 | } 28 | 29 | export async function prompt(questions: PromptOptions[]) { 30 | const answers: Record = {}; 31 | 32 | for(let i = 0; i< questions.length; i++) { 33 | const name = questions[i].name; 34 | 35 | answers[name] = await runPrompt(questions[i]); 36 | } 37 | 38 | return answers; 39 | } 40 | --------------------------------------------------------------------------------