Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : update async-cli package to use ES modules #1716

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/create-glee-app/templates/default/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"target": "es6",
"esModuleInterop": true,
"moduleResolution": "node",
"module": "commonjs",
"module": "ESNext",
"skipLibCheck": true
}
}
4 changes: 2 additions & 2 deletions assets/create-glee-app/templates/tutorial/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"target": "es6",
"esModuleInterop": true,
"moduleResolution": "node",
"module": "commonjs"
"module": "ESNext"
}
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,6 @@
"action:docker:build": "docker build -f github-action/Dockerfile -t asyncapi/github-action-for-cli:latest .",
"action:test": "cd github-action && make test"
},
"types": "lib/index.d.ts"
"types": "lib/index.d.ts",
"type": "module"
}
21 changes: 9 additions & 12 deletions scripts/fetch-asyncapi-example.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
/* eslint-disable @typescript-eslint/no-var-requires */

const fs = require('fs');
const unzipper = require('unzipper');
const path = require('path');

const { Parser } = require('@asyncapi/parser/cjs');
const { AvroSchemaParser } = require('@asyncapi/avro-schema-parser');
const { OpenAPISchemaParser } = require('@asyncapi/openapi-schema-parser');
const { RamlDTSchemaParser } = require('@asyncapi/raml-dt-schema-parser');
const { pipeline } = require('stream');
const { promisify } = require('util');
import fs from 'fs';
import unzipper from 'unzipper';
import path from 'path';
import { Parser } from '@asyncapi/parser';
import { AvroSchemaParser } from '@asyncapi/avro-schema-parser';
import { OpenAPISchemaParser } from '@asyncapi/openapi-schema-parser';
import { RamlDTSchemaParser } from '@asyncapi/raml-dt-schema-parser';
import { pipeline } from 'stream';
import { promisify } from 'util';

const streamPipeline = promisify(pipeline);

Expand Down
31 changes: 15 additions & 16 deletions scripts/releasePackagesRename.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import { rename, access, mkdir } from 'fs/promises';
import packageJson from '../package.json';
import path from 'path';
import simpleGit from 'simple-git';

const { rename, access, mkdir } = require('fs').promises;
const packageJson = require('../package.json');
const path = require('path');
const simpleGit = require('simple-git');
const git = simpleGit({baseDir: process.cwd()});
const git = simpleGit({ baseDir: process.cwd() });

async function fileExists(checkPath) {
try {
Expand All @@ -28,7 +27,7 @@ async function createDirectory(directoryPath) {
}
}

async function renameDeb({version, name, sha}) {
async function renameDeb({ version, name, sha }) {
const dist = 'dist/deb';

// deb package naming convention: https://github.com/oclif/oclif/blob/fb5da961f925fa0eba5c5b05c8cee0c9bd156c00/src/upload-util.ts#L51
Expand All @@ -37,7 +36,7 @@ async function renameDeb({version, name, sha}) {
await checkAndRenameFile(generatedPath, newPath);
}

async function renameTar({version, name, sha}) {
async function renameTar({ version, name, sha }) {
const dist = 'dist';

const generatedPath = path.resolve(dist, `${name}-v${version}-${sha}-linux-x64.tar.gz`);
Expand All @@ -49,15 +48,15 @@ async function renameTar({version, name, sha}) {
await checkAndRenameFile(generatedPath, newPath);
}

async function renameWindows({version, name, sha, arch}) {
async function renameWindows({ version, name, sha, arch }) {
const dist = 'dist/win32';

const generatedPath = path.resolve(dist, `${name}-v${version}-${sha}-${arch}.exe`);
const newPath = path.resolve(dist, `asyncapi.${arch}.exe`);
await checkAndRenameFile(generatedPath, newPath);
}

async function renamePkg({version, name, sha, arch}) {
async function renamePkg({ version, name, sha, arch }) {
const dist = 'dist/macos';

const generatedPath = path.resolve(dist, `${name}-v${version}-${sha}-${arch}.pkg`);
Expand All @@ -69,12 +68,12 @@ async function renamePackages() {
const version = packageJson.version;
const name = 'asyncapi';
const sha = await git.revparse(['--short', 'HEAD']);
await renameDeb({version: version.split('-')[0], name, sha});
await renamePkg({version, name, sha, arch: 'x64'});
await renamePkg({version, name, sha, arch: 'arm64'});
await renameWindows({version, name, sha, arch: 'x64'});
await renameWindows({version, name, sha, arch: 'x86'});
await renameTar({version, name, sha});
await renameDeb({ version: version.split('-')[0], name, sha });
await renamePkg({ version, name, sha, arch: 'x64' });
await renamePkg({ version, name, sha, arch: 'arm64' });
await renameWindows({ version, name, sha, arch: 'x64' });
await renameWindows({ version, name, sha, arch: 'x86' });
await renameTar({ version, name, sha });
}

renamePackages();
4 changes: 2 additions & 2 deletions src/commands/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Command from '../core/base';
import bundle from '@asyncapi/bundler';
import { promises } from 'fs';
import { promises as fsPromises } from 'fs';
import path from 'path';
import { Specification } from '../core/models/SpecificationFile';
import { Document } from '@asyncapi/bundler/lib/document';
import { bundleFlags } from '../core/flags/bundle.flags';

const { writeFile } = promises;
const { writeFile } = fsPromises;

export default class Bundle extends Command {
static readonly description = 'Bundle one or multiple AsyncAPI Documents and their references together.';
Expand Down
2 changes: 0 additions & 2 deletions src/commands/convert.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { promises as fPromises } from 'fs';
import { Args } from '@oclif/core';
import Command from '../core/base';
Expand All @@ -9,7 +8,6 @@ import { convert, convertOpenAPI, convertPostman } from '@asyncapi/converter';
import type { AsyncAPIConvertVersion, OpenAPIConvertVersion } from '@asyncapi/converter';
import { cyan, green } from 'picocolors';
import { proxyFlags } from '../core/flags/proxy.flags';
// @ts-ignore
import specs from '@asyncapi/specs';
import { convertFlags } from '../core/flags/convert.flags';

Expand Down
2 changes: 0 additions & 2 deletions src/commands/generate/fromTemplate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Args } from '@oclif/core';
import Command from '../../core/base';
// eslint-disable-next-line
// @ts-ignore
import AsyncAPIGenerator from '@asyncapi/generator';
import AsyncAPINewGenerator from 'generator-v2';
import path from 'path';
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { run } from '@oclif/core';
import { run } from '@oclif/core';

/**
* For NodeJS < 15, unhandled rejections are treated as warnings.
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"outDir": "./lib",
"baseUrl": "./src",
"target": "es6",
"module": "commonjs",
"module": "ESNext",
"lib": [
"esnext",
],
Expand Down
Loading