Skip to content

Commit

Permalink
Aae 23572 recreate js api lib into a proper nx workspace lib bis (#9917)
Browse files Browse the repository at this point in the history
* back to mocha, working in future node versions

* update package-lock

* change bundle to build

* update node to 18.20.3 [ci:force]

* fix e2es [ci:force]

* bring bundle back to fix e2e [ci:force]

* patch in legacy builds

* Updated package-lock

* Updated executor to new @nx

* Revert "Updated executor to new @nx"

This reverts commit a520ba3.

* Improved ts config reverted changes on @nrwl

---------

Co-authored-by: Wojciech Duda <[email protected]>
  • Loading branch information
VitoAlbano and wojd0 authored Jul 5, 2024
1 parent 764633e commit 9d72d68
Show file tree
Hide file tree
Showing 10 changed files with 4,536 additions and 10,497 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.18.2
18.20.3
5 changes: 1 addition & 4 deletions lib/js-api/.mocharc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"extensions": ["ts"],
"spec": ["lib/js-api/test/**/*.spec.ts"],
"node-option": [
"loader=ts-node/register"
]
"spec": ["dist/tmp/libs/js-api/test/**/*.spec.js"]
}
106 changes: 106 additions & 0 deletions lib/js-api/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"name": "js-api",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "lib/js-api",
"projectType": "library",
"prefix": "adf",
"targets": {
"build": {
"executor": "@nrwl/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/js-api",
"main": "lib/js-api/src/index.ts",
"tsConfig": "lib/js-api/tsconfig.lib.json",
"assets": ["lib/js-api/*.md"],
"externalBuildTargets": [
"build"
]
},
"configurations": {
"test": {
"outputPath": "dist/tmp/libs/js-api",
"tsConfig": "lib/js-api/tsconfig.spec.json",
"assets": [
"lib/js-api/test/mockObjects/assets/**/*"
]
}
}
},
"build-all": {
"executor": "nx:run-commands",
"options": {
"commands": [
"npm run js_api_build"
]
}
},
"publish": {
"executor": "nx:run-commands",
"options": {
"command": "node tools/scripts/publish.mjs lib-js-api {args.ver} {args.tag}"
},
"dependsOn": [
{
"projects": "self",
"target": "build-all"
}
]
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["lib/js-api/**/*.ts"]
}
},
"bundle": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "echo cli bundle created"
}
]
},
"dependsOn": [
"copyToNodeModules"
]
},
"copyToNodeModules": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "rm -rf ./node_modules/@alfresco/js-api/ && mkdir -p ./node_modules/@alfresco/js-api/ && cp -R ./dist/libs/js-api/* ./node_modules/@alfresco/js-api/"
}
]
},
"dependsOn": [
{
"projects": "self",
"target": "build-all"
}
]
},
"test": {
"executor": "nx:run-commands",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"commands": [
"nx run js-api:build:test",
"mocha --full-trace --config lib/js-api/.mocharc.json",
"rm -fr dist/tmp/libs/js-api"
],
"parallel": false
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
},
"tags": []
}
34 changes: 29 additions & 5 deletions lib/js-api/test/oauth2AuthImplicitFlow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ describe('Oauth2 Implicit flow test', () => {
});

it('should redirect to login if access token is not valid', (done) => {
window = globalAny.window = { location: {} };
window = globalAny.window = {
location: {
assign: (v: any) => {
window.location.href = v;
}
}
};
globalAny.document = {
getElementById: () => ''
};
Expand Down Expand Up @@ -81,7 +87,13 @@ describe('Oauth2 Implicit flow test', () => {
});

it('should not loop over redirection when redirectUri contains hash and token is not valid ', (done) => {
window = globalAny.window = { location: {} };
window = globalAny.window = {
location: {
assign: (v: any) => {
window.location.href = v;
}
}
};
globalAny.document = {
getElementById: () => ''
};
Expand Down Expand Up @@ -112,7 +124,13 @@ describe('Oauth2 Implicit flow test', () => {
});

it('should not redirect to login if access token is valid', (done) => {
window = globalAny.window = { location: {} };
window = globalAny.window = {
location: {
assign: (v: any) => {
window.location.href = v;
}
}
};
globalAny.document = {
getElementById: () => ''
};
Expand Down Expand Up @@ -144,11 +162,17 @@ describe('Oauth2 Implicit flow test', () => {
});

it('should set the loginFragment to redirect after the login if it is present', (done) => {
window = globalAny.window = {};
window = globalAny.window = {
location: {
assign: (v: any) => {
window.location.href = v;
}
}
};
globalAny.document = {
getElementById: () => ''
};
window.location = <Location>{ hash: 'asfasfasfa' };
window.location.hash = 'asfasfasfa';

Object.defineProperty(window.location, 'hash', {
writable: true,
Expand Down
4 changes: 1 addition & 3 deletions lib/js-api/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
"esModuleInterop": true,
"isolatedModules": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"types": ["mocha"]
"lib": ["ESNext", "dom"]
}
}
15 changes: 15 additions & 0 deletions lib/js-api/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"moduleResolution": "node",
"target": "ES2015",
"esModuleInterop": true,
"isolatedModules": true,
"allowSyntheticDefaultImports": true,
"lib": ["ESNext", "dom"],
"types": ["mocha"]
},
"exclude": [],
"include": ["**/*"]
}
2 changes: 1 addition & 1 deletion lib/process-services-cloud/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.18.2
18.20.3
Loading

0 comments on commit 9d72d68

Please sign in to comment.