lowcode-engine/scripts/sync-oss.js
2022-12-21 10:18:34 +08:00

48 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
const http = require('http');
const package = require('../packages/engine/package.json');
const { version, name } = package;
const options = {
method: 'PUT',
// 暂时使用 日常环境的 uipaas-node上线后可切换成线上环境 https://uipaas-node.alibaba-inc.com
hostname: 'uipaas-node.alibaba.net',
path: '/staticAssets/cdn/packages',
headers: {
'Content-Type': 'application/json',
Cookie: 'locale=en-us',
},
maxRedirects: 20,
};
const onResponse = function (res) {
const chunks = [];
res.on('data', (chunk) => {
chunks.push(chunk);
});
res.on('end', (chunk) => {
const body = Buffer.concat(chunks);
console.table(JSON.stringify(JSON.parse(body.toString()), null, 2));
});
res.on('error', (error) => {
console.error(error);
});
};
const req = http.request(options, onResponse);
const postData = JSON.stringify({
packages: [
{
packageName: name,
version,
},
],
// 可以发布指定源的 npm 包,默认公网 npm
useTnpm: false,
});
req.write(postData);
req.end();