@opra/cli 0.14.3 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/oprimp.mjs +1 -1
- package/cjs/api-exporter/api-exporter.js +107 -0
- package/cjs/{oprimp → api-exporter}/index.js +1 -1
- package/cjs/api-exporter/process-resources.js +50 -0
- package/cjs/api-exporter/process-types.js +215 -0
- package/cjs/api-exporter/ts-file.js +90 -0
- package/cjs/index.js +1 -1
- package/cjs/{oprimp.js → oprimp-cli.js} +8 -9
- package/esm/api-exporter/api-exporter.js +107 -0
- package/esm/api-exporter/file-writer.js +11 -0
- package/esm/api-exporter/index.js +4 -0
- package/esm/api-exporter/process-resources.js +50 -0
- package/esm/api-exporter/process-types.js +215 -0
- package/esm/api-exporter/ts-file.js +90 -0
- package/esm/index.js +4 -1
- package/esm/interfaces/file-writer.interface.js +2 -1
- package/esm/interfaces/logger.interface.js +2 -1
- package/esm/interfaces/service-generation-context.interface.js +2 -1
- package/esm/oprimp-cli.js +35 -0
- package/esm/utils/get-caller-file.util.js +5 -1
- package/esm/utils/string-utils.js +14 -6
- package/package.json +10 -10
- package/types/api-exporter/api-exporter.d.ts +46 -0
- package/types/api-exporter/index.d.ts +1 -0
- package/types/api-exporter/process-resources.d.ts +6 -0
- package/types/api-exporter/process-types.d.ts +54 -0
- package/types/api-exporter/ts-file.d.ts +18 -0
- package/types/index.d.ts +1 -0
- package/{esm → types}/interfaces/service-generation-context.interface.d.ts +2 -2
- package/cjs/oprimp/delete-files.js +0 -27
- package/cjs/oprimp/generate-service.js +0 -54
- package/cjs/oprimp/process-resoruces.js +0 -59
- package/cjs/oprimp/process-types.js +0 -130
- package/cjs/utils/ts-file.js +0 -55
- package/esm/index.d.ts +0 -1
- package/esm/oprimp/delete-files.d.ts +0 -1
- package/esm/oprimp/delete-files.js +0 -22
- package/esm/oprimp/file-writer.js +0 -6
- package/esm/oprimp/generate-service.d.ts +0 -13
- package/esm/oprimp/generate-service.js +0 -49
- package/esm/oprimp/index.d.ts +0 -1
- package/esm/oprimp/index.js +0 -1
- package/esm/oprimp/process-resoruces.d.ts +0 -2
- package/esm/oprimp/process-resoruces.js +0 -54
- package/esm/oprimp/process-types.d.ts +0 -2
- package/esm/oprimp/process-types.js +0 -125
- package/esm/oprimp.js +0 -33
- package/esm/utils/ts-file.d.ts +0 -11
- package/esm/utils/ts-file.js +0 -50
- /package/cjs/{oprimp → api-exporter}/file-writer.js +0 -0
- /package/{esm/oprimp → types/api-exporter}/file-writer.d.ts +0 -0
- /package/{esm → types}/interfaces/file-writer.interface.d.ts +0 -0
- /package/{esm → types}/interfaces/logger.interface.d.ts +0 -0
- /package/{esm/oprimp.d.ts → types/oprimp-cli.d.ts} +0 -0
- /package/{esm → types}/utils/get-caller-file.util.d.ts +0 -0
- /package/{esm → types}/utils/string-utils.d.ts +0 -0
package/esm/oprimp.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { program } from 'commander';
|
|
3
|
-
import * as console from 'console';
|
|
4
|
-
import * as fs from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import * as process from 'process';
|
|
7
|
-
import { generateService } from './oprimp/generate-service.js';
|
|
8
|
-
import { getCallerFile } from './utils/get-caller-file.util.js';
|
|
9
|
-
const pkgJson = JSON.parse(fs.readFileSync(path.resolve(path.dirname(getCallerFile()), '../package.json'), 'utf-8'));
|
|
10
|
-
program
|
|
11
|
-
.version(pkgJson.version)
|
|
12
|
-
.argument('<serviceUrl>', 'OPRA service url')
|
|
13
|
-
.argument('<outDir>', 'Output directory')
|
|
14
|
-
.option('--name <name>', 'Name of the service')
|
|
15
|
-
.option('--ext', 'Adds js extension to imports')
|
|
16
|
-
.option('--no-color', 'Disables colors in logs messages')
|
|
17
|
-
.action(async (serviceUrl, outDir, options) => {
|
|
18
|
-
if (!options.color)
|
|
19
|
-
chalk.level = 0;
|
|
20
|
-
await generateService({
|
|
21
|
-
serviceUrl,
|
|
22
|
-
outDir,
|
|
23
|
-
name: options.name,
|
|
24
|
-
extension: (options.ext ? '.js' : ''),
|
|
25
|
-
fileHeader: '/*\n' +
|
|
26
|
-
' * Generated by OPRA Service Generator \n' +
|
|
27
|
-
' * Version: ' + pkgJson.version + '\n' +
|
|
28
|
-
' * ' + new Date() + '\n' +
|
|
29
|
-
' */'
|
|
30
|
-
});
|
|
31
|
-
console.log(chalk.greenBright('Completed'));
|
|
32
|
-
});
|
|
33
|
-
program.parse(process.argv);
|
package/esm/utils/ts-file.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ServiceGenerationContext } from '../interfaces/service-generation-context.interface.js';
|
|
2
|
-
export declare class TsFile {
|
|
3
|
-
imports: Record<string, string[]>;
|
|
4
|
-
exports: Record<string, string[]>;
|
|
5
|
-
header: string;
|
|
6
|
-
content: string;
|
|
7
|
-
addImport: (filename: string, ...imported: string[]) => void;
|
|
8
|
-
addExport: (filename: string, ...exported: string[]) => void;
|
|
9
|
-
generate(): string;
|
|
10
|
-
writeFile(ctx: ServiceGenerationContext, filename: string): Promise<void>;
|
|
11
|
-
}
|
package/esm/utils/ts-file.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import flattenText from 'putil-flattentext';
|
|
4
|
-
export class TsFile {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.imports = {};
|
|
7
|
-
this.exports = {};
|
|
8
|
-
this.header = '';
|
|
9
|
-
this.content = '';
|
|
10
|
-
this.addImport = (filename, ...imported) => {
|
|
11
|
-
this.imports[filename] = this.imports[filename] || [];
|
|
12
|
-
imported.forEach(x => {
|
|
13
|
-
if (!this.imports[filename].includes(x))
|
|
14
|
-
this.imports[filename].push(x);
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
this.addExport = (filename, ...exported) => {
|
|
18
|
-
this.exports[filename] = this.exports[filename] || [];
|
|
19
|
-
exported.forEach(x => {
|
|
20
|
-
if (!this.exports[filename].includes(x))
|
|
21
|
-
this.exports[filename].push(x);
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
generate() {
|
|
26
|
-
let output = '/* #!oprimp_auto_generated!# !! Do NOT remove this line */\n' +
|
|
27
|
-
(this.header ? flattenText(this.header) + '\n\n' : '\n');
|
|
28
|
-
const importStr = Object.keys(this.imports)
|
|
29
|
-
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
|
|
30
|
-
.map(i => `import { ${this.imports[i].join(', ')} } from '${i}';`)
|
|
31
|
-
.join('\n');
|
|
32
|
-
if (importStr)
|
|
33
|
-
output += flattenText(importStr) + '\n';
|
|
34
|
-
output += flattenText(this.content);
|
|
35
|
-
const exportStr = Object.keys(this.exports)
|
|
36
|
-
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
|
|
37
|
-
.map(i => {
|
|
38
|
-
const a = this.exports[i];
|
|
39
|
-
return `export ${a.length ? '{' + a.join(', ') + '}' : '*'} from '${i}';`;
|
|
40
|
-
})
|
|
41
|
-
.join('\n');
|
|
42
|
-
if (exportStr)
|
|
43
|
-
output += flattenText(exportStr) + '\n';
|
|
44
|
-
return output;
|
|
45
|
-
}
|
|
46
|
-
async writeFile(ctx, filename) {
|
|
47
|
-
await ctx.writer.writeFile(filename, this.generate());
|
|
48
|
-
ctx.logger.log(' - Written', chalk.whiteBright('./' + path.relative(ctx.absoluteDir, filename)));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|