Skip to content

Commit 982ed60

Browse files
committed
Remove yarn references
update angular code after build address pr feedback Add npm ci step
1 parent 54177d1 commit 982ed60

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+53545
-36322
lines changed

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all"
4+
}

README.md

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# OneSignal React, Vue, & Angular Code Generator
22

33
## NPM Packages
4-
* [React](https://github.com/OneSignal/react-onesignal)
5-
* [Vue](https://github.com/OneSignal/onesignal-vue)
6-
* [Angular](https://github.com/OneSignal/onesignal-ngx)
4+
5+
- [React](https://github.com/OneSignal/react-onesignal)
6+
- [Vue](https://github.com/OneSignal/onesignal-vue)
7+
- [Angular](https://github.com/OneSignal/onesignal-ngx)
78

89
## Start
10+
911
If you just cloned the repo run the command:
1012
`scripts/bootstrap`
1113
`scripts/update-subtrees`
@@ -14,6 +16,7 @@ If you already bootstrapped the remotes you just need to run:
1416
`scripts/update-subtrees`
1517

1618
## Upstream API Spec
19+
1720
The code generator uses an `api.json` spec file from the [OneSignal-Website-SDK](https://github.com/OneSignal/OneSignal-Website-SDK) repo as the input. Modify this file in that repo to change what the generator ultimately builds.
1821

1922
The generator uses the URL hard-coded as a constant in the `src/support/constants.ts` file to fetch the spec. Make sure to update this URL as needed.
@@ -25,40 +28,44 @@ The generator uses the URL hard-coded as a constant in the `src/support/constant
2528
Run the `update-version-numbers` script in the `scripts` folder and input the update type (major, minor, patch, beta).
2629

2730
**Update `README.md` files where needed**
28-
* React: `src/static/react/README.md`
29-
* Vue: `src/static/vue/README.md`
30-
* Angular: `src/static/onesignal-ngx/README.md`
31+
32+
- React: `src/static/react/README.md`
33+
- Vue: `src/static/vue/README.md`
34+
- Angular: `src/static/onesignal-ngx/README.md`
3135

3236
```
33-
yarn build
37+
npm run build
3438
```
3539

36-
*ATTENTION: note regarding hidden files:*
37-
The `settings.json` file in the `.vscode` directory hides all `*.js` files automatically. This is to keep the workspace uncluttered. Alternatively, you can turn those settings off by flipping to `false` and cleaning / decluttering with the command `yarn clean` (see below).
40+
_ATTENTION: note regarding hidden files:_
41+
The `settings.json` file in the `.vscode` directory hides all `*.js` files automatically. This is to keep the workspace uncluttered. Alternatively, you can turn those settings off by flipping to `false`.
3842

3943
## Publishing
44+
4045
1. Merge your changes to `main` to kick off the build and cd_update process. Or trigger the workflow manually through the "Submit Downstream PRs" Github Actions workflow.
4146
2. Review the downstream PR (branch `cd_update`) and merge into each respective SDK's `main` or feature branch (e.g: `user-model/v1`).
4247
3. Pull the remote changes via `git pull` for the SDKs.
4348
4. Publish with `npm publish .`
44-
* For onesignal-vue3 you must pass the `--access public` to the publish command as it is a scoped package.
45-
* For **beta releases** run `npm publish --tag beta`
49+
- For onesignal-vue3 you must pass the `--access public` to the publish command as it is a scoped package.
50+
- For **beta releases** run `npm publish --tag beta`
4651

4752
## Special Types File
53+
4854
The repo contains a file `types.ts` that contains all the type definitions for arguments and return values. These types must be kept updated (synchronized) with the upstream. To add new ones:
55+
4956
- add the type to `src/snippets/types.ts`
5057
- write the type via `TypingsWriterManagerBase.ts`
5158

52-
## Cleaning
53-
You can clean the generated `.js` files by running `yarn clean`
54-
5559
## Compatibility
60+
5661
As frameworks put out new major releases, we should ensure our shims remain compatible with the new versions.
5762

5863
### Vue 2 & 3
64+
5965
There were some breaking changes in Vue 3 that required the plugin to be updated to support it. Instead of making a major release, we opted to create a separate plugin: `onesignal-vue3` as this will greatly simplify managing future major releases (e.g: w/ user-model).
6066

6167
### Angular
68+
6269
Angular puts out a new major release more frequently: once or twice per year. Our plugin is almost a pure JS module with the exception of a couple imports including `Injectable` needed for the eventual dependency injection. These are:
6370

6471
```js
@@ -68,17 +75,21 @@ import { Injectable, NgModule, Component, OnInit } from '@angular/core';
6875
It is unlikely that Angular would introduce a regression in a future release, in particular with `Injectable` which is our main dependency injection method. For context, it is a decorator (e.g: `@Injectable()`) which Angular uses to know what to inject. However, keep an eye out for changes related to any of these when looking to determine compatibility.
6976

7077
# Dev Environment
78+
7179
Set up a new React, Vue, or Angular App so the new app and final package repo is at the same directory level as this project.
7280

7381
**Angular Example:**
82+
7483
```
7584
|_ web-shim-codegen // code generator
7685
|_ my-example-app // your example app
7786
|_ onesignal-ngx // npm package
7887
```
7988

8089
## Creating Test Apps
90+
8191
### React Example App
92+
8293
```
8394
cd ~/tmp
8495
npx create-react-app web-shim-test-react --template typescript
@@ -87,6 +98,7 @@ npm link {YOUR_PATH_HERE}/web-shim-codegen/build/react
8798
```
8899

89100
### Vue Example App
101+
90102
```
91103
cd ~/tmp
92104
npm create vue@latest vue-web-shim-test
@@ -95,6 +107,7 @@ npm link {YOUR_PATH_HERE}/web-shim-codegen/build/vue/v3
95107
```
96108

97109
### Angular Example App
110+
98111
```
99112
cd ~/tmp
100113
ng new angular-example-app
@@ -103,24 +116,38 @@ npm link {YOUR_PATH_HERE}/web-shim-codegen/build/onesignal-ngx
103116
```
104117

105118
## Link Builds with Local Project
119+
106120
Creates a symlink to allow test projects to automatically pick up changes from builds.
121+
107122
### React
123+
108124
`npm link {YOUR_PATH_HERE}/web-shim-codegen/build/react`
125+
109126
### Vue3
127+
110128
`npm link {YOUR_PATH_HERE}/web-shim-codegen/build/vue/v3`
129+
111130
### Vue2
131+
112132
`npm link {YOUR_PATH_HERE}/web-shim-codegen/build/vue/v2`
133+
113134
### Angular
135+
114136
`npm link {YOUR_PATH_HERE}/web-shim-codegen/build/onesignal-ngx`
115137

116138
## Rebuilding to test changes to package
117-
Run `yarn build` here to rebuild all packages
118-
* Your test projects should automatically be pick up the changes, since `npm link` does a symlink for you.
139+
140+
Run `npm run build` here to rebuild all packages
141+
142+
- Your test projects should automatically be pick up the changes, since `npm link` does a symlink for you.
119143

120144
## Troubleshooting
145+
121146
### Changes not showing in your test project?
122-
* Try re-link with the `npm link ...` command noted above, as the symlink may have broken
123-
* Try removing the file's top level package import and re-importing via VSCode auto-import (start typing package name, hit enter)
147+
148+
- Try re-link with the `npm link ...` command noted above, as the symlink may have broken
149+
- Try removing the file's top level package import and re-importing via VSCode auto-import (start typing package name, hit enter)
124150

125151
### Check the module
152+
126153
Check the package in the `node_modules` directory to see if it is updated with latest changes

0 commit comments

Comments
 (0)