Change build setup of JS clients, reintroduce beta publishing after losing it due to unmerged code (#238)

This commit is contained in:
Janos Dobronszki
2021-10-22 09:49:47 +01:00
committed by GitHub
parent 7cc2a86d0f
commit 293d5ecdde
140 changed files with 13946 additions and 643 deletions

View File

@@ -1 +1,9 @@
node_modules
dist
es
lib
types
tmp
index.js
index.d.ts
esm

91
cmd/clients/ts/build.js Normal file
View File

@@ -0,0 +1,91 @@
const chalk = require('chalk');
const path = require('path');
const fs = require('fs');
const rimraf = require('rimraf');
const { ncp } = require('ncp');
function getTmpEsmDirectories() {
return fs
.readdirSync('./tmp/esm')
.filter(file => fs.statSync(`./tmp/esm/${file}`).isDirectory());
}
function log(text) {
console.log(`${chalk.cyan('M3O JS:')} ${text}`);
}
function writeModulePackageJsonFile(location) {
fs.writeFileSync(
`${location}/package.json`,
`{"module": "./esm/index.js"}`,
'utf8'
);
}
function deleteDirectory(directory) {
return new Promise(resolve => {
rimraf(directory, err => {
resolve();
});
});
}
function copyAllTmpFolders() {
return new Promise((resolve, reject) => {
// Now copy to root level
ncp(path.join(__dirname, 'tmp'), __dirname, err => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}
function moveToLocalEsmFolders() {
return new Promise((resolve, reject) => {
const esmDirs = getTmpEsmDirectories();
// Move the files around in tmp...
esmDirs.forEach(dir => {
const currentPath = path.join(__dirname, 'tmp/esm', dir);
fs.readdirSync(currentPath).forEach(async file => {
const currentFilePath = path.join(currentPath, file);
const newFilePath = path.join(__dirname, 'tmp', dir, 'esm', file);
const esmFolderLocation = path.join(__dirname, 'tmp', dir, 'esm');
try {
if (!fs.existsSync(esmFolderLocation)) {
fs.mkdirSync(esmFolderLocation);
}
fs.renameSync(currentFilePath, newFilePath);
writeModulePackageJsonFile(`./tmp/${dir}`);
await deleteDirectory(`./tmp/esm/${dir}`);
} catch (err) {
reject(err);
}
});
});
log('Moved local esm folders');
resolve();
});
}
async function build() {
log('Moving to correct folders');
try {
await moveToLocalEsmFolders();
await copyAllTmpFolders();
writeModulePackageJsonFile('./tmp/esm');
await deleteDirectory('./tmp');
} catch (e) {
console.log(e);
}
}
build();

File diff suppressed because it is too large Load Diff

View File

@@ -1,26 +1,31 @@
{
"name": "m3o",
"version": "1.0.1",
"description": "",
"main": "dist",
"types": "dist/index.d.ts",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/micro/services"
},
"author": "",
"license": "ISC",
"scripts": {
"build": "tsc",
"prepare": "npm run build",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"typescript": "^3.5.1"
},
"dependencies": {
"@m3o/m3o-node": "^0.0.24"
},
"exports": {}
"name": "m3o",
"version": "1.0.1",
"types": "index.d.ts",
"main": "index.js",
"module": "esm/index.js",
"files": [],
"repository": {
"type": "git",
"url": "https://github.com/micro/services"
},
"author": "",
"license": "ISC",
"scripts": {
"clean": "rimraf ./tmp",
"build": "npm run clean && tsc && tsc --p tsconfig.es.json && node build.js",
"prepare": "npm run build"
},
"dependencies": {
"@m3o/m3o-node": "^0.0.24",
"@types/estree": "^0.0.47",
"chalk": "^2.4.2",
"move-file": "^3.0.0",
"ncp": "^2.0.0",
"rimraf": "^3.0.2"
},
"devDependencies": {
"prettier": "^2.4.1",
"typescript": "^3.5.1"
}
}

View File

@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "ES2015",
"target": "ES6",
"declaration": true,
"lib": ["es2015", "dom"],
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"outDir": "./tmp/esm",
"strict": true,
"moduleResolution": "node",
"esModuleInterop": true
},
"include": ["src/index.ts", "src/**/*"],
"exclude": ["./dist", "./node_modules"]
}

View File

@@ -1,16 +1,16 @@
{
"compilerOptions": {
"module": "es6",
"module": "CommonJS",
"target": "es5",
"declaration": true,
"lib": ["es2015", "dom"],
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"outDir": "./dist",
"outDir": "./tmp",
"strict": true,
"moduleResolution": "node",
"esModuleInterop": true
},
"include": ["index.ts", "./*"],
"exclude": ["src/**/*.spec.*", "./dist", "./node_modules"]
"include": ["src/index.ts", "src/**/*"],
"exclude": ["./dist", "./node_modules"]
}