Skip to content

Commit

Permalink
feat: switch to esm
Browse files Browse the repository at this point in the history
  • Loading branch information
Arun-KumarH committed Feb 12, 2024
1 parent 352ce29 commit decc59c
Show file tree
Hide file tree
Showing 22 changed files with 197 additions and 265 deletions.
11 changes: 11 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
extends: './node_modules/@restorecommerce/dev/.eslintrc.cjs',
parserOptions: {
project: [
'tsconfig.json',
],
},
rules: {
'@typescript-eslint/consistent-type-imports': 0
}
};
81 changes: 0 additions & 81 deletions .eslintrc.js

This file was deleted.

40 changes: 14 additions & 26 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ on: push

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup NodeJS
uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: '20.8.0'
node-version-file: '.nvmrc'

- name: Install Dependencies
run: npm ci
Expand All @@ -21,54 +19,44 @@ jobs:
run: npm run build

test:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup NodeJS
uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: '20.8.0'
node-version-file: '.nvmrc'

- name: Setup System
uses: restorecommerce/setup-system-action@v1
- uses: restorecommerce/setup-system-action@v1

- name: Install Dependencies
run: npm ci

- name: Test
run: npm run test && npm run lcov-report

- name: Coveralls
uses: coverallsapp/github-action@master
- uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

image:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup buildx
uses: docker/setup-buildx-action@v1
- uses: docker/setup-buildx-action@v3

- name: Set variables
id: vars
run: |
echo ::set-output name=version_tag::$(echo ${GITHUB_REF#refs/*/})
echo ::set-output name=repo_name::$(echo ${GITHUB_REPOSITORY#*/*})
- name: Build
uses: docker/build-push-action@v2
- uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: false
build-args: |
APP_HOME=/home/node/${{ steps.vars.outputs.repo_name }}
cache-from: |
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/pr-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Lint PR"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

permissions:
pull-requests: read

jobs:
main:
name: pr-lint
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62 changes: 32 additions & 30 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
name: release
name: Release

on:
push:
tags:
- v*
branches:
- master

permissions:
contents: read

jobs:
release:
runs-on: ubuntu-20.04
permissions:
contents: write
issues: write
pull-requests: write
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Login to DockerHub
uses: docker/login-action@v1
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}

- uses: docker/setup-buildx-action@v1
- uses: docker/setup-buildx-action@v3
with:
install: true

Expand All @@ -34,28 +38,26 @@ jobs:
run: |
echo ::set-output name=repo_name::$(echo ${GITHUB_REPOSITORY#*/*})
- name: Docker meta
- uses: docker/metadata-action@v5
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
tag-sha: true
tag-semver: |
{{version}}
{{major}}.{{minor}}
- name: Build and push
uses: docker/build-push-action@v2
images: ${{ github.repository }}

- uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
load: true
build-args: |
APP_HOME=/home/node/${{ steps.vars.outputs.repo_name }}
cache-from: |
${{ github.repository }}:latest
tags: ${{ steps.docker_meta.outputs.tags }}
tags: ${{ github.repository }}
labels: ${{ steps.docker_meta.outputs.labels }}

- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'

- name: Install Dependencies
run: npm clean-install

- run: npx [email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 5 additions & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"extension": ["ts"],
"spec": "test/**/*.spec.ts",
"require": "ts-node/register"
"require": "ts-node/register",
"node-option": [
"experimental-specifier-resolution=node",
"loader=ts-node/esm"
]
}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.8
19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
"cross-fetch": "^4.0.0",
"graphql-tag": "^2.12.6",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"node-eval": "^2.0.0",
"traverse": "^0.6.8"
},
"devDependencies": {
"@alenon/grpc-mock-server": "^3.1.9",
"@grpc/proto-loader": "^0.7.10",
"@restorecommerce/protos": "^6.7.0",
"@types/lodash": "^4.14.202",
"@types/lodash-es": "^4.17.12",
"@types/mocha": "^10.0.6",
"@types/nock": "^11.1.0",
"@types/node": "^20.11.17",
Expand All @@ -60,11 +60,12 @@
"should": "^13.2.3",
"ts-node": "^10.9.2",
"tslint": "^6.1.3",
"typescript": "^5.3.3"
"typescript": "^5.3.3",
"esbuild": "^0.20.0"
},
"scripts": {
"start": "node lib/start.js",
"dev": "cross-env NODE_ENV=development nodemon --watch './src/**/*.ts' --exec 'ts-node' src/start.ts",
"dev": "cross-env NODE_ENV=development nodemon --watch './src/**/*.ts' --exec node --loader ts-node/esm ./src/start.ts",
"test": "npm run build && npm run lint && nyc npm run mocha",
"lint": "eslint src --ext .ts",
"mocha": "cross-env NODE_ENV=test mocha --full-trace --exit --timeout 120000",
Expand All @@ -73,11 +74,13 @@
"lcov-report": "nyc report --reporter=lcov",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"tsctests": "tsc -d -p tsconfig.test.json",
"build:tsc": "tsc -d",
"build:tsc": "esbuild ./src/start.ts --bundle --platform=node --outfile=lib/start.js --minify --tree-shaking=true --sourcemap=inline",
"build:jobs": "find ./src/jobs -maxdepth 1 -type f -exec bash -c 'esbuild {} --bundle --platform=node --outfile=lib/jobs/$(basename {} .ts).js --minify --tree-shaking=true --sourcemap=inline' \\;",
"build:clean": "rimraf lib",
"build": "npm-run-all lint build:clean build:tsc"
"build": "npm-run-all lint build:clean build:tsc build:jobs"
},
"engines": {
"node": ">= 18.0.0"
}
"node": ">= 20.8.0"
},
"type": "module"
}
12 changes: 6 additions & 6 deletions src/accessControlService.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import * as _ from 'lodash';
import * as _ from 'lodash-es';
import { Server } from '@restorecommerce/chassis-srv';
import { Events } from '@restorecommerce/kafka-client';

import { CommandInterface } from '@restorecommerce/chassis-srv';
import { ResourceManager } from './resourceManager';
import { ResourceManager } from './resourceManager.js';
import { RedisClientType } from 'redis';

import * as core from './core';
import * as core from './core.js';
import { Logger } from 'winston';
import {
AccessControlServiceImplementation, ReverseQuery,
Request, Response, DeepPartial, Response_Decision
} from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/access_control';
} from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/access_control.js';
import {
CommandInterfaceServiceImplementation
} from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/commandinterface';
import { PolicySetWithCombinables } from './core/interfaces';
} from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/commandinterface.js';
import { PolicySetWithCombinables } from './core/interfaces.js';

export class AccessControlService implements AccessControlServiceImplementation {
cfg: any;
Expand Down
Loading

0 comments on commit decc59c

Please sign in to comment.