Skip to content
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 .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
'plugin:react/recommended',
],
parserOptions: {
ecmaVersion: 2018,
ecmaVersion: 2020,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
Expand Down
40 changes: 3 additions & 37 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
jobs:
test:
name: test
name: Test and Publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup
uses: actions/setup-node@v2
with:
node-version: '14.x'
- uses: actions/cache@v1
node-version: '18.x'
- uses: actions/cache@v2
id: yarn-cache
with:
path: node_modules
Expand All @@ -30,40 +30,6 @@ jobs:
run: yarn lint
- name: Build
run: yarn build
- name: Test
run: yarn test

publish:
name: Publish
needs: test
if: |
github.event_name == 'push'
&& (
contains(github.ref, 'refs/heads/next')
|| contains(github.ref, 'refs/heads/main')
|| contains(github.ref, 'refs/heads/next-major')
|| contains(github.ref, 'refs/heads/beta')
)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup
uses: actions/setup-node@v2
with:
node-version: '14.x'
- uses: actions/cache@v1
id: yarn-cache
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node_modules-
- name: Install
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install
- name: Build
run: yarn build
- name: Release
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
Expand Down
File renamed without changes.
5 changes: 0 additions & 5 deletions jest.config.js

This file was deleted.

66 changes: 29 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{
"name": "@adminjs/import-export",
"version": "2.0.2",
"main": "lib/index.js",
"types": "types/index.d.ts",
"type": "module",
"exports": {
".": {
"import": "./lib/index.js",
"types": "./types/index.d.ts"
}
},
"private": false,
"repository": "[email protected]:SoftwareBrothers/adminjs-import-export.git",
"license": "SEE LICENSE IN LICENSE",
"scripts": {
"release": "semantic-release",
"build": "tsc",
"dev": "tsc --watch",
"test": "jest",
"lint": "eslint './src/**/*'",
"check:all": "yarn lint && yarn build && yarn test"
"lint": "eslint './src/**/*'"
},
"husky": {
"hooks": {
Expand All @@ -24,43 +27,32 @@
"adminjs": "^6.0.0"
},
"devDependencies": {
"@adminjs/design-system": "^3.1.0",
"@adminjs/express": "^4.0.1",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@semantic-release/git": "^9.0.0",
"@types/express": "^4.17.9",
"@types/jest": "^26.0.15",
"@types/json2csv": "^5.0.1",
"@types/xml": "^1.0.5",
"@types/xml2js": "^0.4.5",
"@typescript-eslint/eslint-plugin": "^4.6.0",
"@typescript-eslint/parser": "^4.6.0",
"adminjs": "^6.0.0",
"date-fns": "^2.16.1",
"eslint": "^7.12.1",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.21.5",
"express": "^4.17.1",
"express-formidable": "^1.2.0",
"express-session": "^1.17.2",
"@adminjs/design-system": "^4.0.0-beta-v4.1",
"@commitlint/cli": "^17.4.4",
"@commitlint/config-conventional": "^17.4.4",
"@semantic-release/git": "^10.0.1",
"@types/json2csv": "^5.0.3",
"@types/xml": "^1.0.8",
"@types/xml2js": "^0.4.11",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"adminjs": "^7.0.0-beta-v7.1",
"date-fns": "^2.29.3",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.32.2",
"husky": "^4.3.0",
"jest": "^26.6.1",
"prettier": "^2.7.1",
"semantic-release": "^17.2.2",
"ts-jest": "^26.4.3",
"ts-node": "^9.0.0",
"typescript": "^4.0.5"
"prettier": "^2.8.6",
"semantic-release": "^20.1.3",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
},
"dependencies": {
"@adminjs/mongoose": "^2.0.0",
"@types/mongoose": "^5.7.37",
"csvtojson": "^2.0.10",
"file-saver": "^2.0.2",
"file-saver": "^2.0.5",
"json2csv": "^5.0.3",
"mongoose": "^5.10.11",
"xml": "^1.0.1",
"xml2js": "^0.4.23"
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/ExportComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import React, { FC, useState } from 'react';
import { ActionProps, ApiClient, useNotice } from 'adminjs';
import { Box, Button, Loader, Text } from '@adminjs/design-system';
import { saveAs } from 'file-saver';
import { Exporters, ExporterType } from '../exporter.type';
import format from 'date-fns/format';

import { Exporters, ExporterType } from '../exporter.type.js';

export const mimeTypes: Record<ExporterType, string> = {
json: 'application/json',
csv: 'text/csv',
Expand Down
5 changes: 3 additions & 2 deletions src/export.handler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Parsers } from './parsers';
import { getRecords } from './utils';
import { ActionHandler, ActionResponse } from 'adminjs';

import { Parsers } from './parsers.js';
import { getRecords } from './utils.js';

export const exportHandler: ActionHandler<ActionResponse> = async (
request,
response,
Expand Down
2 changes: 1 addition & 1 deletion src/exporter.type.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const Exporters = ['csv', 'json', 'xml'] as const;

export type ExporterType = typeof Exporters[number];
export type ExporterType = (typeof Exporters)[number];
3 changes: 2 additions & 1 deletion src/import.handler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ActionHandler, ActionResponse } from 'adminjs';
import fs from 'fs';
import util from 'util';
import { getFileFromRequest, getImporterByFileName } from './utils';

import { getFileFromRequest, getImporterByFileName } from './utils.js';

const readFile = util.promisify(fs.readFile);

Expand Down
9 changes: 5 additions & 4 deletions src/importExportFeature.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { buildFeature, FeatureType } from 'adminjs';
import { bundleComponents } from './components/bundleComponents';
import { postActionHandler } from './utils';
import { exportHandler } from './export.handler';
import { importHandler } from './import.handler';

import { bundleComponents } from './components/bundleComponents.js';
import { postActionHandler } from './utils.js';
import { exportHandler } from './export.handler.js';
import { importHandler } from './import.handler.js';

const { EXPORT_COMPONENT, IMPORT_COMPONENT } = bundleComponents();

Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @section modules
*/

import importExportFeature from './importExportFeature';
import importExportFeature from './importExportFeature.js';

export * from './components/bundleComponents';
export * from './components/bundleComponents.js';

export default importExportFeature;
5 changes: 3 additions & 2 deletions src/modules/csv/csv.importer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import csv from 'csvtojson';
import { Importer } from '../../parsers';
import { saveRecords } from '../../utils';

import { Importer } from '../../parsers.js';
import { saveRecords } from '../../utils.js';

export const csvImporter: Importer = async (csvString, resource) => {
const records = await csv().fromString(csvString);
Expand Down
4 changes: 2 additions & 2 deletions src/modules/json/json.importer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Importer } from '../../parsers';
import { saveRecords } from '../../utils';
import { Importer } from '../../parsers.js';
import { saveRecords } from '../../utils.js';

export const jsonImporter: Importer = async (jsonString, resource) => {
const records = JSON.parse(jsonString);
Expand Down
5 changes: 3 additions & 2 deletions src/modules/xml/xml.importer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Importer } from '../../parsers';
import xml2js from 'xml2js';
import { saveRecords } from '../../utils';

import { Importer } from '../../parsers.js';
import { saveRecords } from '../../utils.js';

export const xmlImporter: Importer = async (xmlString, resource) => {
const parser = new xml2js.Parser({ explicitArray: false });
Expand Down
15 changes: 8 additions & 7 deletions src/parsers.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { BaseRecord, BaseResource } from 'adminjs';
import { ExporterType } from './exporter.type';
import { jsonExporter } from './modules/json/json.exporter';
import { jsonImporter } from './modules/json/json.importer';
import { csvExporter } from './modules/csv/csv.exporter';
import { xmlExporter } from './modules/xml/xml.exporter';
import { csvImporter } from './modules/csv/csv.importer';
import { xmlImporter } from './modules/xml/xml.importer';

import { ExporterType } from './exporter.type.js';
import { jsonExporter } from './modules/json/json.exporter.js';
import { jsonImporter } from './modules/json/json.importer.js';
import { csvExporter } from './modules/csv/csv.exporter.js';
import { xmlExporter } from './modules/xml/xml.exporter.js';
import { csvImporter } from './modules/csv/csv.importer.js';
import { xmlImporter } from './modules/xml/xml.importer.js';

export type Exporter = (records: BaseRecord[]) => string;

Expand Down
9 changes: 5 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import {
Filter,
ValidationError,
} from 'adminjs';
import { csvImporter } from './modules/csv/csv.importer';
import { jsonImporter } from './modules/json/json.importer';
import { xmlImporter } from './modules/xml/xml.importer';
import { Importer } from './parsers';

import { csvImporter } from './modules/csv/csv.importer.js';
import { jsonImporter } from './modules/json/json.importer.js';
import { xmlImporter } from './modules/xml/xml.importer.js';
import { Importer } from './parsers.js';

export const saveRecords = async (
records: Record<string, any>[],
Expand Down
58 changes: 0 additions & 58 deletions test/export-csv.test.ts

This file was deleted.

5 changes: 0 additions & 5 deletions test/feature.test.ts

This file was deleted.

6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es2017",
"target": "esnext",
"esModuleInterop": true,
"jsx": "preserve",
"declaration": true,
Expand All @@ -10,8 +10,8 @@
"strictFunctionTypes": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"moduleResolution": "node",
"module": "commonjs",
"moduleResolution": "nodenext",
"module": "nodenext",
"baseUrl": ".",
"outDir": "lib",
"declarationDir": "types",
Expand Down
Loading