Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
im3x
Scriptables
Repository navigation
Code
Issues
9
(9)
Pull requests
2
(2)
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
v2-dev
Breadcrumbs
Scriptables
/
pack.js
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
45 lines (37 loc) · 1.52 KB
v2-dev
Breadcrumbs
Scriptables
/
pack.js
Copy path
Top
File metadata and controls
Code
Blame
45 lines (37 loc) · 1.52 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
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
44
45
/**
* 打包成单独小组件
* 用法:
* node pack.js Scripts/「源码」小组件示例.js
* 将会在`Dist`目录生成「小件件」小组件示例.js 文件,这个文件可以发送给用户单独使用
*/
const process = require('process')
const os = require('os')
const fs = require('fs')
const path = require('path')
if (process.argv.length !== 3) {
console.log('[!] 用法:node pack Scripts/「源码」xxx.js')
process.exit(0)
}
const SAVE_PATH = path.join(__dirname, "Dist")
const file_name = process.argv[2]
const out_name = file_name.replace("「源码」", "「小件件」").replace("Scripts", "Dist")
// 创建目录
if (!fs.existsSync(SAVE_PATH)) {
fs.mkdirSync(SAVE_PATH)
}
// 组合文件
const runtime_file = fs.readFileSync(path.join(__dirname, "Scripts", "「小件件」开发环境.js"))
const runtime_code = runtime_file.toString("utf-8").split("// @running.end")[0]
const widget_file = fs.readFileSync(path.join(__dirname, file_name))
const widget_code = widget_file.toString("utf-8");
const widget_class = widget_code.split("// @组件代码开始")[1].split("// @组件代码结束")[0]
const widget_header = widget_code.split('// icon-color:')[1].split('\n')[0];
let result_code = `// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color:${widget_header}
${runtime_code}
${widget_class}
await Running(Widget)`
// 写入文件
fs.writeFileSync(path.join(__dirname, out_name), result_code)
console.log('[*] 文件已经保存到:' + out_name)
You can’t perform that action at this time.