Skip to content

Commit

Permalink
Merge pull request #7 from UniversityOfNicosia/chore/sync-fork
Browse files Browse the repository at this point in the history
Chore: Synchronize chore/sync-fork with Mainstream Updates and Enhancements
  • Loading branch information
HlexNC authored Apr 24, 2024
2 parents 0c0999a + 3ff5ac1 commit e64fb26
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 4,836 deletions.
4 changes: 3 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"extensions": [
"ms-azuretools.vscode-docker",
"github.vscode-github-actions",
"mhutchie.git-graph"
"mhutchie.git-graph",
"GitHub.copilot",
"GitHub.copilot-chat"
]
}
}
Expand Down
11 changes: 4 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
version: 2
updates:
updates:
- package-ecosystem: "npm"
directory: "/officegen-api"
schedule:
interval: "weekly"
day: "monday"
interval: "daily"
reviewers:
- "HlexNC"

- package-ecosystem: "pip"
directory: "/python-api"
schedule:
interval: "weekly"
day: "monday"
interval: "daily"
reviewers:
- "HlexNC"

- package-ecosystem: "npm"
directory: "/privateomega-lib"
schedule:
interval: "weekly"
day: "monday"
interval: "daily"
reviewers:
- "HlexNC"

Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/dependabot-batcher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'Dependabot Batcher: Scheduled'
on:
schedule:
- cron: '0 9 * * 5'

jobs:
dependabot-batcher:
name: 'Combine Dependabot PRs'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
token: ${{ secrets.BATCHER_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: 'Dependabot Batcher'
uses: Legal-and-General/[email protected]
with:
token: ${{ secrets.BATCHER_TOKEN }}

45 changes: 38 additions & 7 deletions .github/workflows/publish-conversion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,53 @@ name: Publish Document Conversion NPM Package

on:
push:
branches:
- main
branches: [ "main" ]

permissions:
contents: write
packages: write

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
registry-url: 'https://npm.pkg.github.com'
scope: '@universityofnicosia'
- run: npm install

- name: Install dependencies
run: npm install
working-directory: privateomega-lib/

- name: Publish package
id: publish
run: npm publish
working-directory: privateomega-lib/
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true

- name: Increment package version
if: steps.publish.outcome == 'failure'
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git pull origin
npm version patch
git add .
git commit -m "chore: bump version [skip ci]"
git push
working-directory: privateomega-lib/

- name: Publish package again
if: steps.publish.outcome == 'failure'
run: npm publish
working-directory: privateomega-lib/
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45 changes: 38 additions & 7 deletions .github/workflows/publish-gen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,53 @@ name: Publish Document Gen NPM Package

on:
push:
branches:
- main
branches: [ "main" ]

permissions:
contents: write
packages: write

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
registry-url: 'https://npm.pkg.github.com'
scope: '@universityofnicosia'
- run: npm install

- name: Install dependencies
run: npm install
working-directory: officegen-api/

- name: Publish package
id: publish
run: npm publish
working-directory: officegen-api/
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true

- name: Increment package version
if: steps.publish.outcome == 'failure'
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git pull origin
npm version patch
git add .
git commit -m "chore: bump version [skip ci]"
git push
working-directory: officegen-api/

- name: Publish package again
if: steps.publish.outcome == 'failure'
run: npm publish
working-directory: officegen-api/
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions officegen-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock.json
40 changes: 20 additions & 20 deletions officegen-api/examples/library-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

The UNIC Document Generator Library is a powerful Node.js module that enables the creation of `.docx` documents from structured JSON inputs. Built on top of the `officegen` library, it offers a flexible way to generate documents with custom styles and various elements such as text, titles, subtitles, lists, bullets, and footnotes.

This guide covers the process of setting up, installing, and using this private NPM package within your projects.
This guide details the setup, installation, and usage process of this NPM package within your projects.

## Prerequisites

Before you begin, ensure you have the following installed:
Ensure the following are installed before proceeding:
- Node.js (v12.x or higher recommended)
- npm (usually comes with Node.js)
- npm (comes bundled with Node.js)

## Installation

Expand All @@ -31,38 +31,38 @@ Since this package is hosted on the GitHub Packages registry associated with the

## Setting Up Your Project

1. **Create a new Node.js project** (if you haven't already) by running `npm init` in your project directory and following the prompts.
1. **Initialize a new Node.js project** (if not already done) by executing `npm init` in your project directory and completing the setup prompts.

2. **Install the UNIC Document Gen Library** using the command provided in the Installation section above.

## Usage

To use the library, you need to import it into your Node.js application, configure your document structure and styles in JSON format, and call the library function to create a document.
Import the library into your Node.js application, configure your document structure and styles in JSON, and invoke the library function to create a document.

### Basic Example

Here's a basic example of how to use the library:
Here's a simple example demonstrating the library usage:
```javascript
const documentLibrary = require('@universityofnicosia/unic-document-gen-library');
// Define your document structure and styles
const inputJson = {
elements: [
{ type: 'title', text: 'Document Title' },
{ type: 'subtitle', text: 'Subtitle Here' },
{ type: 'paragraph', text: 'This is a simple paragraph.' },
"elements": [
{ "type": "title", "text": "Document Title" },
{ "type": "subtitle", "text": "Subtitle Here" },
{ "type": "paragraph", "text": "This is a simple paragraph." },
{
type: 'list',
items: ['First item', 'Second item', 'Third item']
"type": "list",
"items": ["First item", "Second item", "Third item"]
}
],
styles: {
fontFamily: {
title: 'Arial',
body: 'Calibri'
"styles": {
"fontFamily": {
"title": "Arial",
"body": "Calibri"
},
textColor: '#000000'
"textColor": "#000000"
}
};
Expand All @@ -74,16 +74,16 @@ documentLibrary.createDocumentWithStructure(inputJson)
### Error Handling
The library provides error handling mechanisms. Ensure your application properly catches and handles these errors, especially for invalid inputs or issues during document generation.
It's crucial to implement error handling in your application to manage any potential issues, such as invalid inputs or problems during document generation.

## Advanced Usage

For more complex documents, refer to the `officegen` documentation to understand all supported elements and styles. The UNIC Document Generator Library supports these features as part of the `inputJson` configuration.

## Contributing

We welcome contributions! If you have suggestions for improvements or encounter any issues, please file a report in the repository's issues section.
Contributions are highly appreciated! If you have improvement suggestions or encounter any issues, please submit them via the project's issue tracker.
## License
This library is provided under the [MIT License](https://opensource.org/licenses/MIT). Please review the license terms before using or contributing to the project.
This library is distributed under the [MIT License](https://opensource.org/licenses/MIT). Ensure you review the license terms before utilizing or contributing to the project.
Loading

0 comments on commit e64fb26

Please sign in to comment.