Skip to content

Commit

Permalink
Merge pull request #1 from primno/doc
Browse files Browse the repository at this point in the history
Publish package to npm
  • Loading branch information
xaviermonin authored Mar 12, 2023
2 parents ac05670 + 8c6fc1d commit 78d2f0f
Show file tree
Hide file tree
Showing 52 changed files with 1,032 additions and 2,762 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build

on:
push:
branches: [ main ]

pull_request:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '18.x'

- name: Install dependencies and build
run: |
npm ci
npm run build
20 changes: 20 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Publish Core

on:
release:
types: [created]

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ node_modules/
.pnp.*

# Primno CLI
dist/tsc.js
dist/tsc.mjs
build/
.nyc_output
.cache
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# .npmrc
engine-strict=true
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Primno
Copyright (c) 2023 Xavier Monin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
# Primno CLI

Primno CLI is used to manage Primno project from the command line.
[![npm](https://img.shields.io/npm/v/@primno/cli.svg)](https://www.npmjs.com/package/@primno/cli)
[![npm](https://img.shields.io/npm/l/@primno/cli.svg)](https://github.com/primno/cli/blob/main/LICENSE)
![build](https://img.shields.io/github/actions/workflow/status/primno/cli/build.yml)

Primno CLI is a command-line interface tool for initializing, building, and deploying Primno projects from a command shell.

> **Important**
> primno is in beta stage and subject to change.
## Documentation

The documentation can be found on [https://primno.io](https://primno.io).

- [Getting Started](https://primno.io/docs/getting-started)
- [Guides](https://primno.io/docs/guides)
- [API Reference](https://primno.io/docs/api-reference)

## Commands

Expand Down
2 changes: 1 addition & 1 deletion dist/index.js → dist/index.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env node

require('./tsc.js');
import './tsc.mjs';
14 changes: 7 additions & 7 deletions dist/schema/primno.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@
"build": {
"$ref": "#/definitions/Build"
},
"environnement": {
"environment": {
"type": "array",
"items": {
"$ref": "#/definitions/Environnement"
"$ref": "#/definitions/Environment"
}
}
},
"required": [
"build",
"distDir",
"entryPointDir",
"environnement",
"environment",
"name",
"serve",
"sourceRoot",
Expand All @@ -54,7 +54,7 @@
"type": "object",
"additionalProperties": false,
"properties": {
"environnement": {
"environment": {
"type": "string"
},
"entryPoint": {
Expand All @@ -66,11 +66,11 @@
},
"required": [
"entryPoint",
"environnement"
"environment"
],
"title": "Build"
},
"Environnement": {
"Environment": {
"type": "object",
"additionalProperties": false,
"properties": {
Expand All @@ -89,7 +89,7 @@
"name",
"production"
],
"title": "Environnement"
"title": "Environment"
},
"Serve": {
"type": "object",
Expand Down
11 changes: 11 additions & 0 deletions dist/template/new/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Node.js
node_modules/

# VSCode
.vscode/

# Primno
.cache
dist
build
primno.env.json
2 changes: 2 additions & 0 deletions dist/template/new/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# .npmrc
engine-strict=true
25 changes: 25 additions & 0 deletions dist/template/new/README.md.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,31 @@ Primno is a Typescript framework for Model-Driven Apps (PowerApps / Dynamics 365

To learn more about Primno, visit [Primno](https://primno.io/) web site.

## File structure

The initial file structure looks like this:

```bash
{{ name }}
├── node_modules
├── src # Source code directory
│ ├── list # List (home-grid, sub-grid and associated-grid) components
│ │ ├── contact.component.ts # Component that say hello when a button is clicked on a contact grid
│ │ └── list.module.ts # Main module of the components tree of page type "list"
│ ├── record # Record (form) components
│ │ ├── account # Account component and its sub-components
│ │ │ ├── account.component.ts # Component that runs when on account form.
│ │ │ └── notify-column-change.component.ts # Sub-component of AccountComponent
│ │ └── record.module.ts # Main module of the components tree of page type "list"
│ └── entry-point # Entry points for Power Apps (JS web-resources)
│ └── main.ts # Main entry point with its main module. Load list and record modules.
├── package.json
├── primno.config.json # Primno configuration file
├── primno.env.json # Primno environment configuration file.
├── README.md
├── .gitignore
└── tsconfig.json

## Install

To install this project, run:
Expand Down
8 changes: 6 additions & 2 deletions dist/template/new/package.json.template
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"devDependencies": {},
"name": "{{ name }}",
"engines": {
"node": ">=16.0.0"
},
"scripts": {
"start": "mn start",
"build:prod": "mn build -p",
"build:dev": "mn build",
"start": "mn start",
"watch": "mn watch"
"watch": "mn watch",
"deploy": "mn deploy"
},
"dependencies": {}
}
37 changes: 0 additions & 37 deletions dist/template/new/src/app/app.component.ts

This file was deleted.

26 changes: 0 additions & 26 deletions dist/template/new/src/app/app.module.ts

This file was deleted.

6 changes: 0 additions & 6 deletions dist/template/new/src/entry-point/app.ts

This file was deleted.

26 changes: 26 additions & 0 deletions dist/template/new/src/entry-point/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** Read README.md first */

import { MnModule } from "@primno/core";
import { ListModule } from "../list/list.module";
import { RecordModule } from "../record/record.module";

/**
* An entry point corresponds to a JS web resource that will be deployed to PowerApps / Dynamics 365.
* The main module must be exported here to be loaded and run by Primno.
*/

/**
* The {@link MainModule} class is defined as a module by the {@link MnModule} decorator.
* A module is a container of components / sub-modules.
*
* {@link MainModule} is the primary module for this entry point and imports the {@link RecordModule} and {@link ListModule}.
* The `bootstrap` components defined in these sub-modules will be started when the entry point is loaded.
*
* In this architecture, {@link RecordModule} is the primary module for the page type `record`
* while {@link ListModule} is for the page type `list`.
* Each page type must have their own component tree (separated boot), this architecture allows for a clear separation.
*/
@MnModule({
imports: [RecordModule, ListModule]
})
export class MainModule {}
29 changes: 29 additions & 0 deletions dist/template/new/src/list/contact.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { CommandBarEventArg, MnComponent, MnOnCommandInvoke } from "@primno/core";

/**
* The {@link ContactComponent} class is defined as a component by the {@link @MnComponent} decorator.
* This component runs on lists (sub-grid, home-grid, associated-grid) of the `contact` table.
*/
@MnComponent({
scope: {
pageType: "list",
table: "contact"
}
})
export class ContactComponent {

/**
* sayHello is an event handler that will be called
* when the user click on the command bar button "hello" due to the {@link MnOnCommandInvoke} decorator.
*
* To works, this event must be manually added in the command bar of `contact` table
* by calling the `mn_main.onCommandInvoke` method with the parameters:
* - A string parameter with the name `hello` (the name of the command)
* - SelectedControl
* - PrimaryControl
*/
@MnOnCommandInvoke("hello")
public sayHello(eventArg: CommandBarEventArg) {
Xrm.Navigation.openAlertDialog({ text: "Hello from Primno." });
}
}
26 changes: 26 additions & 0 deletions dist/template/new/src/list/list.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { MnModule } from "@primno/core";
import { ContactComponent } from "./contact.component";

/**
* The AppModule class is defined as a module by the {@link MnModule} decorator.
* A module is a container of components.
*/
@MnModule({
/**
* The bootstrap property defines that {@link RecordComponent} will be the root component of this module
* and will be created when the module is loaded.
*/
bootstrap: ContactComponent,
/**
* The declarations property defines the components that will be available to be child components of the others components of this module.
* In this case, the {@link RecordComponent} is the only component of this module.
* If you want to create a component that will be a child of the {@link RecordComponent}, you must define it in the declarations property.
* A component can be declared in only one module.
*/
declarations: [
ContactComponent
]
})
export class ListModule {

}
Loading

0 comments on commit 78d2f0f

Please sign in to comment.