
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
grunt-spm-server
Advanced tools
A Grunt task plugin, transport `CommonJS` module dynamically for `SeaJS` environment.
A Grunt task plugin, transport
CommonJSmodule dynamically forSeaJSenvironment.
Grunt 插件:通过 Web 服务实时地转换 CommonJS 模块以方便 SeaJS 环境中的开发调试。
$ npm install --save-dev grunt-spm-server
grunt.initConfig({
server: {
// 开发环境
develop: {
options: {
// API mocking 文件存放目录
api: './mock',
// 指向上级目录
base: '..',
release: false
}
},
// 仿真线上环境
release: {
options: {
base: '..',
release: true
}
}
}
});
$ grunt server:develop
$ grunt server:release
Type: `Array | String`
config 文件模板路径,可选。
Type: `String`
config 文件存放路径,可选,默认 `'lib/config.js'`。
Type: `String`
API mocking 文件存放目录。
// json
{
"/url/to/foo": {
"POST": {
"code": 0,
"message": "POST ok",
"notice_id": "xxxxxxx"
},
"PATCH": {
"code": 0,
"message": "PATCH ok",
"notice_id": "xxxxxxx"
}
},
"/url/to/bar": {
// asterisk match any RESTful request method
"*": {
"code": 0,
"message": "ok"
}
}
}
// or js
module.exports = {
'/foo/bar': {
// function is support
'GET': function(url, query) {
return {
'MOCKAPI': {
// means redirect
'status': '302',
'location': '/foo/bar' + query.match(/id=([^&]+)/)[1] + '.png'
}
};
}
}
};
Type: `String`
Default value: `'.'`
Web 服务根目录。
Type: `Boolean`
Default value: `true`
是否生成 config 文件。
Type: `Number`
Default value: `8851`
Web 服务侦听端口。
Type: `Boolean`
Default value: `true`
是否模拟线上环境,为 `true` 则不执行服务端 wrapping。
Type: `Function | RegExp`
路径匹配函数,可选,返回 `true` 则执行服务端 wrapping。
function(url, query, idleading) {
if (query.indexOf('nowrap') !== -1) {
return false;
}
if (idleading) {
if (idleading.indexOf('..') !== -1) {
url = url.replace(/^\/[^\/]+/, '');
} else if (url.indexOf('/' + idleading) !== -1) {
url = url.substring(idleading.length + 1);
}
}
// 默认匹配
return /^\/(((app|mod|spm_modules|src).+)|index)\.(css|handlebars|json|js)$/.test(url);
}
// or RegExp
/^\/(((app|mod|spm_modules|src).+)|index)\.(css|handlebars|json|js)$/
FAQs
A Grunt task plugin, transport `CommonJS` module dynamically for `SeaJS` environment.
The npm package grunt-spm-server receives a total of 2,245 weekly downloads. As such, grunt-spm-server popularity was classified as popular.
We found that grunt-spm-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.