From 6ddc49f52319ce7c482462107789f14f359bdfb9 Mon Sep 17 00:00:00 2001 From: Wojciech Duda <69160975+wojd0@users.noreply.github.com> Date: Wed, 3 Jul 2024 15:55:56 +0200 Subject: [PATCH] AAE-23572 missing files --- .prettierignore | 3 ++ jest.config.ts | 5 ++++ jest.preset.js | 3 ++ lib/js-api-old/.eslintrc.json | 51 +++++++++++++++++++++++++++++++++ lib/js-api-old/.mocharc.json | 7 +++++ lib/js-api-old/README.md | 52 ++++++++++++++++++++++++++++++++++ lib/js-api-old/package.json | 26 +++++++++++++++++ lib/js-api-old/tsconfig.json | 24 ++++++++++++++++ lib/js-api/jest.config.ts | 11 ++++++++ lib/js-api/project.json | 51 +++++++++++++++++++++++++++++++++ lib/js-api/tsconfig.lib.json | 10 +++++++ lib/js-api/tsconfig.spec.json | 9 ++++++ tools/scripts/publish.mjs | 53 +++++++++++++++++++++++++++++++++++ 13 files changed, 305 insertions(+) create mode 100644 .prettierignore create mode 100644 jest.config.ts create mode 100644 jest.preset.js create mode 100644 lib/js-api-old/.eslintrc.json create mode 100644 lib/js-api-old/.mocharc.json create mode 100644 lib/js-api-old/README.md create mode 100644 lib/js-api-old/package.json create mode 100644 lib/js-api-old/tsconfig.json create mode 100644 lib/js-api/jest.config.ts create mode 100644 lib/js-api/project.json create mode 100644 lib/js-api/tsconfig.lib.json create mode 100644 lib/js-api/tsconfig.spec.json create mode 100644 tools/scripts/publish.mjs diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000000..9481e77eda --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +# Add files here to ignore them from prettier formatting +/dist +/coverage \ No newline at end of file diff --git a/jest.config.ts b/jest.config.ts new file mode 100644 index 0000000000..0d1a49d15a --- /dev/null +++ b/jest.config.ts @@ -0,0 +1,5 @@ +import { getJestProjects } from '@nrwl/jest'; + +export default { + projects: getJestProjects() +}; diff --git a/jest.preset.js b/jest.preset.js new file mode 100644 index 0000000000..e6c8ebea00 --- /dev/null +++ b/jest.preset.js @@ -0,0 +1,3 @@ +const nxPreset = require('@nrwl/jest/preset').default; + +module.exports = { ...nxPreset }; diff --git a/lib/js-api-old/.eslintrc.json b/lib/js-api-old/.eslintrc.json new file mode 100644 index 0000000000..80ab800720 --- /dev/null +++ b/lib/js-api-old/.eslintrc.json @@ -0,0 +1,51 @@ +{ + "extends": ["../../.eslintrc.js"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "extends": ["plugin:@nrwl/nx/angular"], + "rules": { + "no-underscore-dangle": ["warn", { "allowAfterThis": true }], + "@typescript-eslint/dot-notation": "off", + "@typescript-eslint/explicit-member-accessibility": [ + "off", + { + "accessibility": "explicit" + } + ], + "@typescript-eslint/no-inferrable-types": "off", + "@typescript-eslint/no-require-imports": "off", + "@typescript-eslint/no-var-requires": "error", + "comma-dangle": "error", + "default-case": "error", + "import/order": "off", + "max-len": [ + "error", + { + "code": 240 + } + ], + "no-bitwise": "off", + "no-duplicate-imports": "error", + "no-multiple-empty-lines": "error", + "no-return-await": "error", + + "unicorn/filename-case": "off", + "@typescript-eslint/no-unused-expressions": "off", + "@typescript-eslint/consistent-type-assertions": "off", + "jsdoc/check-param-names": "off", + "jsdoc/require-returns": "off", + "jsdoc/require-param": "off", + "jsdoc/check-tag-names": "off", + "@typescript-eslint/no-shadow": "warn", + "@typescript-eslint/member-ordering": "off", + "@typescript-eslint/no-namespace": "off", + "@typescript-eslint/consistent-type-definitions": "off", + "no-redeclare": "off", + "space-before-function-paren": "off", + "@typescript-eslint/no-empty-interface": "warn" + } + } + ] +} diff --git a/lib/js-api-old/.mocharc.json b/lib/js-api-old/.mocharc.json new file mode 100644 index 0000000000..77c6823278 --- /dev/null +++ b/lib/js-api-old/.mocharc.json @@ -0,0 +1,7 @@ +{ + "extensions": ["ts"], + "spec": ["lib/js-api/test/**/*.spec.ts"], + "node-option": [ + "loader=ts-node/register" + ] +} diff --git a/lib/js-api-old/README.md b/lib/js-api-old/README.md new file mode 100644 index 0000000000..4555f7d289 --- /dev/null +++ b/lib/js-api-old/README.md @@ -0,0 +1,52 @@ +# Alfresco JavaScript API + +JavaScript client API for the Alfresco REST API and Activiti REST API. + +## API clients documentation + +- [Authentication Api](src/api/auth-rest-api/README.md) +- [Content Api](src/api/content-rest-api/README.md) +- [Model Api](src/api/model-rest-api/README.md) +- [Process Api (AAE)](src/api/activiti-rest-api/README.md) +- [Search Api](src/api/search-rest-api/README.md) +- [Governance Classification Api](src/api/gs-classification-rest-api/README.md) +- [Governance Core Api](src/api/gs-core-rest-api/README.md) +- [Discovery Content API](src/api/discovery-rest-api/README.md) + +## Guides + +- [Authentication](docs/authentication.md) +- [Calling Custom Endpoints](docs/calling-custom-endpoints.md) +- [Error Events](docs/error-events.md) +- [ECM Examples](docs/ecm-example.md), full docs: [Content API](src/api/content-rest-api/README.md) +- [BPM Examples](docs/bpm-example.md), full docs: [APS 2.X API](src/api/activiti-rest-api/README.md) + +## Prerequisites + +The minimal supported versions are: + +- Alfresco Platform Repository: version [5.2.a-EA](https://wiki.alfresco.com/wiki/Community_file_list_201606-EA) or newer +- Activiti: 1.5 +- Node.js ([Long Term Support](https://nodejs.org/en/) version) + +## Installing + +Using NPM: + +```sh +npm install @alfresco/js-api +``` + +## Development + +To run the build + +```sh +npm run build +``` + +To run the test + +```sh +npm run test +``` diff --git a/lib/js-api-old/package.json b/lib/js-api-old/package.json new file mode 100644 index 0000000000..60666b6875 --- /dev/null +++ b/lib/js-api-old/package.json @@ -0,0 +1,26 @@ +{ + "name": "@alfresco/js-api-old", + "version": "7.8.0", + "license": "Apache-2.0", + "description": "JavaScript client library for the Alfresco REST API", + "author": "Hyland Software, Inc. and its affiliates", + "keywords": [ + "alfresco" + ], + "repository": { + "type": "git", + "url": "https://github.com/Alfresco/alfresco-ng2-components.git" + }, + "bugs": { + "url": "https://github.com/Alfresco/alfresco-ng2-components/issues" + }, + "dependencies": { + "event-emitter": "^0.3.5", + "superagent": "^9.0.1", + "tslib": "^2.6.1" + }, + "main": "./index.js", + "typings": "./typings/index.d.ts", + "module": "./esm5/index.js", + "es2015": "./esm2015/index.js" +} diff --git a/lib/js-api-old/tsconfig.json b/lib/js-api-old/tsconfig.json new file mode 100644 index 0000000000..c4d1b98a8f --- /dev/null +++ b/lib/js-api-old/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "importHelpers": true, + "removeComments": true, + "preserveConstEnums": true, + "sourceMap": true, + "strictFunctionTypes": true, + "noImplicitAny": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "moduleResolution": "node", + "stripInternal": false, + "target": "es2015", + "outDir": "./.out", + "lib": ["es2018", "dom"], + "typeRoots": ["node_modules/@types"], + "types": [] + }, + "exclude": [".history", "*/node_modules", "config", "performance", "coverage", "node_modules", "package", "dist", "test"] +} diff --git a/lib/js-api/jest.config.ts b/lib/js-api/jest.config.ts new file mode 100644 index 0000000000..d59c99eced --- /dev/null +++ b/lib/js-api/jest.config.ts @@ -0,0 +1,11 @@ +/* eslint-disable */ +export default { + displayName: 'js-api', + preset: '../../jest.preset.js', + transform: { + '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }] + }, + moduleFileExtensions: ['ts', 'js', 'html'], + coverageDirectory: '../../coverage/lib/js-api', + testEnvironment: 'jsdom' +}; diff --git a/lib/js-api/project.json b/lib/js-api/project.json new file mode 100644 index 0000000000..fc4a83c594 --- /dev/null +++ b/lib/js-api/project.json @@ -0,0 +1,51 @@ +{ + "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" + ] + } + }, + "publish": { + "executor": "nx:run-commands", + "options": { + "command": "node tools/scripts/publish.mjs lib-js-api {args.ver} {args.tag}" + }, + "dependsOn": ["build"] + }, + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["lib/js-api/**/*.ts"] + } + }, + "test": { + "executor": "@nrwl/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "lib/js-api/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + } + }, + "tags": [] +} diff --git a/lib/js-api/tsconfig.lib.json b/lib/js-api/tsconfig.lib.json new file mode 100644 index 0000000000..0b83e556f1 --- /dev/null +++ b/lib/js-api/tsconfig.lib.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "declaration": true, + "types": ["node"] + }, + "exclude": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts"], + "include": ["**/*.ts"] +} diff --git a/lib/js-api/tsconfig.spec.json b/lib/js-api/tsconfig.spec.json new file mode 100644 index 0000000000..f15cc39fea --- /dev/null +++ b/lib/js-api/tsconfig.spec.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node", "@types/jest"] + }, + "include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"] +} diff --git a/tools/scripts/publish.mjs b/tools/scripts/publish.mjs new file mode 100644 index 0000000000..377a578f42 --- /dev/null +++ b/tools/scripts/publish.mjs @@ -0,0 +1,53 @@ +/** + * This is a minimal script to publish your package to "npm". + * This is meant to be used as-is or customize as you see fit. + * + * This script is executed on "dist/path/to/library" as "cwd" by default. + * + * You might need to authenticate with NPM before running this script. + */ + +import { readCachedProjectGraph } from '@nrwl/devkit'; +import { execSync } from 'child_process'; +import { readFileSync, writeFileSync } from 'fs'; +import chalk from 'chalk'; + +function invariant(condition, message) { + if (!condition) { + console.error(chalk.bold.red(message)); + process.exit(1); + } +} + +// Executing publish script: node path/to/publish.mjs {name} --version {version} --tag {tag} +// Default "tag" to "next" so we won't publish the "latest" tag by accident. +const [, , name, version, tag = 'next'] = process.argv; + +// A simple SemVer validation to validate the version +const validVersion = /^\d+\.\d+\.\d+(-\w+\.\d+)?/; +invariant( + version && validVersion.test(version), + `No version provided or version did not match Semantic Versioning, expected: #.#.#-tag.# or #.#.#, got ${version}.` +); + +const graph = readCachedProjectGraph(); +const project = graph.nodes[name]; + +invariant(project, `Could not find project "${name}" in the workspace. Is the project.json configured correctly?`); + +const outputPath = project.data?.targets?.build?.options?.outputPath; +invariant(outputPath, `Could not find "build.options.outputPath" of project "${name}". Is project.json configured correctly?`); + +process.chdir(outputPath); + +// Updating the version in "package.json" before publishing +try { + const json = JSON.parse(readFileSync(`package.json`).toString()); + json.version = version; + writeFileSync(`package.json`, JSON.stringify(json, null, 2)); +} catch (e) { + console.error(chalk.bold.red(`Error reading package.json file from library build output.`)); +} + +// Execute "npm publish" to publish +execSync(`npm publish --access public --tag ${tag}`);