Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Commit aa14f0c

Browse files
authored
Merge pull request #1783 from l-lin/dt-2
DT v2 + Project structure upgrades
2 parents 705f26c + e473f9d commit aa14f0c

File tree

179 files changed

+11415
-20671
lines changed

Some content is hidden

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

179 files changed

+11415
-20671
lines changed

.github/CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Got a Question or Problem?
22

3-
You can ask questions by posting an issue. There is no problem, I'll just add the label `question`.
3+
You can ask questions by opening a discussion. We want to strictly restrict issues section for bug reports.
44

55
However, please follow those simple guidelines before posting:
66

7-
1. Describe your issue in an understandable english (english is not my native language, but I still try to write something decent, and so should you).
7+
1. Describe your issue in an understandable English (English is not my native language, but I still try to write something decent, and so should you).
88
2. Please be polite (and occasionally avoid being a beggar... :unamused:).
9-
3. Provide a code to illustrate your issue. A [plnkr](http://plnkr.co/) or something alike is better.
9+
3. Provide a StackBlitz link or GitHub repo to reproduce the issue. It can help speed-up investigating your issue faster.
1010
4. Github provides us a wonderful [Markdown](https://help.github.com/articles/github-flavored-markdown) (text-to-HTML), so use it without restraint, especially when putting your code.
1111
5. Some really good advices on how to ask question:
1212
* on [StackOverflow](http://stackoverflow.com/help/how-to-ask)

.github/workflows/build.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,12 @@ jobs:
2828
run: npm install
2929

3030
- name: Run build
31-
run: npm run build
32-
33-
- name: Pack library
34-
run: npm pack
35-
36-
# test demo
37-
- name: Install demo dependencies
38-
working-directory: ./demo
39-
run: npm install
31+
run: npm run build:lib
4032

4133
- name: Install current angular-datatables to demo
4234
working-directory: ./demo
43-
run: rm -rf node_modules/angular-datatables && npm install --no-save --no-package-lock ../angular-datatables-*.tgz
35+
run: npm run link:lib
4436

4537
- name: Run demo test
4638
working-directory: ./demo
47-
run: npm run test-ci
39+
run: npm run demo:test-ci

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ jobs:
1919
run: npm install
2020

2121
- name: Run build
22-
run: npm run build
22+
run: npm run build:lib
2323

2424
- name: Publish to NPM packages
2525
# includes a --ignore-scripts command argument to avoid executing npm life cycle scripts during this phase
2626
# for security concerns as scripts could steal NODE_AUTH_TOKEN
27-
run: npm publish --ignore-scripts --access public
27+
run: cd dist/lib && npm publish --ignore-scripts --access public
2828
env:
2929
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3030

.gitignore

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,54 @@ _test-output
1313
_temp
1414
.vscode
1515

16-
!karma*.js
17-
!protractor*.js
18-
!systemjs.config.js
1916
!demo/src/**/*.js
20-
!rollup.conf.js
21-
!rollup-uglify.conf.js
2217

2318
# angular-datatables specific
2419
*.js.map
2520
*.d.ts
2621
*.metadata.json
2722
index*.js
23+
24+
# See http://help.github.com/ignore-files/ for more about ignoring files.
25+
26+
# compiled output
27+
/dist
28+
/tmp
29+
/out-tsc
30+
31+
# dependencies
32+
/node_modules
33+
34+
# IDEs and editors
35+
/.idea
36+
.project
37+
.classpath
38+
.c9/
39+
*.launch
40+
.settings/
41+
*.sublime-workspace
42+
43+
# IDE - VSCode
44+
.vscode/*
45+
!.vscode/settings.json
46+
!.vscode/tasks.json
47+
!.vscode/launch.json
48+
!.vscode/extensions.json
49+
50+
# misc
51+
/.angular/cache
52+
/.sass-cache
53+
/connect.lock
54+
/coverage
55+
/libpeerconnection.log
56+
npm-debug.log
57+
testem.log
58+
/typings
59+
60+
# e2e
61+
/e2e/*.js
62+
/e2e/*.map
63+
64+
# System Files
65+
.DS_Store
66+
Thumbs.db

.npmignore

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ node_modules
3030
/.eslintignore
3131
/.eslintrc
3232

33-
# Build System files
34-
/tslint.json
35-
/rollup-uglify.conf.js
36-
/rollup.conf.js
37-
/protractor.config.js
38-
/systemjs.config.js
39-
4033
# Typescript source files
4134
*.ts
4235
!*.d.ts
@@ -54,8 +47,6 @@ tsconfig-build.json
5447
.vscode
5548

5649
# test cases
57-
karma-test-shim.js
58-
karma.conf.js
5950
test
6051
_test-output
6152

DEVELOPER.md

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Node.js and npm are essential to Angular development.
66

77
[Get it now](https://docs.npmjs.com/getting-started/installing-node) if it's not already installed on your machine.
88

9-
**Verify that you are running at least node `v10.x.x` and npm `6.x.x`**
9+
**Verify that you are running at least node `v18.19.x` and npm `10.2.x`**
1010
by running `node -v` and `npm -v` in a terminal/console window.
1111
Older versions produce errors.
1212

@@ -27,7 +27,7 @@ cd angular-datatables
2727
2828
Install the npm packages described in the `package.json` and verify that it works:
2929

30-
**Attention Windows Developers: You must run all of these commands in administrator mode**.
30+
**Attention Windows Developers: You must run all of these commands in administrator mode**.
3131

3232
```bash
3333
npm install
@@ -40,11 +40,9 @@ The `npm run build` command compiles the library,
4040

4141
We've captured many of the most useful commands in npm scripts defined in the `package.json`:
4242

43-
- `npm run tsc` - runs the TypeScript compiler once.
44-
- `npm run tsc:w` - runs the TypeScript compiler in watch mode; the process keeps running, awaiting changes to TypeScript files and re-compiling when it sees them.
45-
with excellent support for Angular apps that use routing.
46-
- `npm test` - compiles, runs and watches the karma unit tests
47-
- `npm build` - compiles and generate the JS files
43+
- `npm start` - Run the demo/docs app locally.
44+
- `npm demo:test` - compiles, runs and watches the karma unit tests (`*.spec.ts` files)
45+
- `npm run build:lib` - compiles and generates prod builds for this library
4846

4947
### Updating dependencies version
5048

@@ -56,47 +54,55 @@ ncu -u
5654
rm -rf node_modules && npm install
5755
```
5856

59-
If you want to update angular, use the cli:
57+
If you want to update Angular to latest version:
6058

6159
```bash
6260
ng update @angular/cli @angular/core
6361
```
6462

63+
You can also install a specific Angular version using the below code:
64+
65+
```bash
66+
# Downgrade to Angular 15
67+
ng update @angular/cli@15 @angular/core@15
68+
```
69+
6570
## Testing
6671

6772
These tools are configured for specific conventions described below.
6873

69-
*It is unwise and rarely possible to run the application, the unit tests, and the e2e tests at the same time.
70-
We recommend that you shut down one before starting another.*
74+
> It is unwise and rarely possible to run the application and the unit tests at the same time.
75+
>
76+
> We recommend that you shut down one before starting another.
7177
7278
### Unit Tests
7379

74-
TypeScript unit-tests are usually in the `src` folder. Their filenames must end in `.spec`.
80+
Unit tests are essential for ensuring that the library remains compatible with the constantly evolving Angular framework. The more tests, the better :)
81+
82+
You can find these tests in the `demo/src` folder, easily recognizable by their filenames ending with `xxx.spec.ts`.
7583

76-
Look for the example `src/angular-datatables.directive.spec.ts`.
77-
Add more `.spec.ts` files as you wish; we configured karma to find them.
84+
For instance: `demo/src/app/app.component.spec.ts`
7885

79-
Run it with `npm test`
86+
Feel free to add more `.spec.ts` files as needed; karma is set up to locate them.
8087

81-
That command first compiles the application, then simultaneously re-compiles and runs the karma test-runner.
82-
Both the compiler and the karma watch for (different) file changes.
88+
To run the tests, simply use `npm run demo:test`
8389

84-
Shut it down manually with Ctrl-C.
90+
This command will compile the application first, then proceed to re-compile and run the karma test-runner simultaneously.
91+
Both the compiler and karma will be on the lookout for any file changes.
8592

86-
Test-runner output appears in the terminal window.
87-
We can update our app and our tests in real-time, keeping a weather eye on the console for broken tests.
88-
Karma is occasionally confused and it is often necessary to shut down its browser or even shut the command down (Ctrl-C) and
89-
restart it. No worries; it's pretty quick.
93+
The test-runner output will be displayed in the terminal window.
9094

91-
The `HTML-Reporter` is also wired in. That produces a prettier output; look for it in `~_test-output/tests.html`.
95+
By updating our app and tests in real-time, we can keep an eye on the console for any failing tests.
96+
97+
Karma (test runner) is occasionally confused and it is often necessary to shut down its browser or even shut the command down (Ctrl-C) and restart it. No worries; it's pretty quick.
9298

9399
## Deploying the documentation to Github Pages
94100

95101
Run `deploy-doc.sh` to deploy the documentation to the Github Pages
96102

97103
You may need to have the following:
98104

99-
- git
105+
- `git`
100106
- have the basic commands in your OS
101107

102108
```bash
@@ -128,13 +134,15 @@ publishes automatically to NPM repository.
128134

129135
# Angular Schematics
130136

137+
We use Angular Schematics for `ng add` functionality.
138+
131139
To build the schematics, issue the following command:
132140

133-
`npm run schematics:build`
141+
`npm run lib:schematics:build`
134142

135143
## Testing
136144

137-
To test schematics, you will need to setup `verdaccio`, deploy the lib locally in your machine, then install it via `ng add` in an Angular project.
145+
To test schematics, you will need to setup `verdaccio`, publish the library locally in your machine, then install it via `ng add` in another Angular project, preferably a newly created one in another terminal window.
138146

139147
### Steps
140148

@@ -144,33 +152,41 @@ To test schematics, you will need to setup `verdaccio`, deploy the lib locally i
144152

145153
2. Start `verdaccio` server on a terminal or (command prompt if on Windows) by running:
146154

147-
`verdaccio`
155+
`verdaccio`
148156

149157
3. Setup an account in `verdaccio` so you can publish the library on your machine:
150158

151-
- Run `npm adduser --registry=http://localhost:4873`
152-
- Give a username, password and an email address to create an account in `verdaccio`.
159+
- Run `npm adduser --registry=http://localhost:4873`
160+
- Give a username, password and an email address to create an account in `verdaccio`.
161+
162+
4. Make your changes in the project.
153163

154-
4. Now, publish the library to `verdaccio` by running the command:
164+
5. Run `npm run build:lib` to build the library and `ng add` functionality related code.
155165

156-
`npm publish angular-datatables --registry http://localhost:4873`
166+
6. Now, publish the library to `verdaccio` by running the command:
167+
168+
```sh
169+
# Make sure you compiled the library first!
170+
# `npm run build:lib`
171+
cd dist/lib
172+
npm publish --registry http://localhost:4873
173+
```
157174

158175
5. Create an empty Angular project like:
159176

160-
`ng new my-demo-project`
177+
`ng new my-demo-project`
161178

162179
6. Install `angular-datatables` to this demo project by running:
163180

164-
`ng add --registry=http://localhost:4873 angular-datatables`
181+
`ng add --registry=http://localhost:4873 angular-datatables`
165182

166183
### Notes
167184

168185
1. The `--registry` flag informs `npm` to use `verdaccio` instead of NPM's registry server.
169186
2. If you're facing issues with `ng add` not grabbing code from `verdaccio`, try setting npm registry endpoint to `verdaccio` like:
170187

171-
`npm set registry http://localhost:4873`
172-
173-
3. Do remember to reset step 2 or else `npm` will stop working whenever `verdaccio` is offline!
188+
`npm config set registry http://localhost:4873`
174189

175-
`npm set registry https://registry.npmjs.org`
190+
3. Remember to reset changes made in step 2 or else `npm` will stop working when `verdaccio` is killed.
176191

192+
`npm config set registry https://registry.npmjs.org`

0 commit comments

Comments
 (0)