fake-data-npm 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@ on:
4
4
  push:
5
5
  branches:
6
6
  - master
7
+ - main
7
8
  tags:
8
9
  - 'v*.*.*'
9
10
 
@@ -26,11 +27,18 @@ jobs:
26
27
  - name: Build
27
28
  run: npm run build
28
29
 
30
+ - name: Run tests
31
+ run: npm test
32
+
29
33
  - name: Publish to npm
30
- if: github.ref_type == 'tag' || github.ref == 'refs/heads/master'
34
+ if: github.ref_type == 'tag' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
31
35
  env:
32
36
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
33
37
  run: |
34
- # publish to the public registry and github package (if needed)
38
+ # publish to the public registry
35
39
  npm publish
36
- npm publish --registry=https://npm.pkg.github.com/fox3000foxy
40
+ # conditionally publish to GitHub Packages (requires scoped name)
41
+ name=$(node -p "require('./package.json').name")
42
+ if [[ "$name" == @* ]]; then
43
+ npm publish --registry=https://npm.pkg.github.com/${{ github.repository_owner }}
44
+ fi
package/README.md CHANGED
@@ -34,7 +34,7 @@ npm run clean # remove build output
34
34
  import { generateFakeProfile } from 'fake-data-npm';
35
35
 
36
36
  const profile = generateFakeProfile({ countryName: 'France', birthGender: 'female' });
37
- console.log(profile); // JSON string
37
+ console.log(profile); // Profile object with typed fields
38
38
 
39
39
  // other helpers:
40
40
  import {
@@ -47,7 +47,7 @@ import {
47
47
  console.log(generatePhoneNumber('+33')); // +33xxxxxxxxx
48
48
  ```
49
49
 
50
- You can also generate batches and export CSV:
50
+ You can also generate batches (now typed as `Profile[]`) and export CSV:
51
51
 
52
52
  ```ts
53
53
  import { generateAndComposeCSV } from 'fake-data-npm';
@@ -60,23 +60,58 @@ console.log(csv.split('\n').length);
60
60
  | Function | Description |
61
61
  |----------|-------------|
62
62
  | `randomItem(arr)` | Return random element from array |
63
+ | `shuffleArray(arr)` | In-place Fisher–Yates shuffle |
64
+ | `randomUUID()` | RFC‑4122 v4 UUID string |
65
+ | `generatePassword(len?)` | Simple alphanumeric password |
63
66
  | `generatePhoneNumber(countryCode)` | Fake phone number |
64
- | `generateSocialHandleVariant(name,surname,pseudo,media)` | Variant
67
+ | `generateSocialHandleVariant(name,surname,pseudo,media)` | Variant |
65
68
  | `generateRandomDigits(length)` | String of digits |
66
69
  | `buildCredibleEmailAddress(first,last,country)` | Email generator |
67
70
  | `generateCreditCard()` | Fake CC data |
68
71
  | `getRandomUsername()` | Get from internal list |
69
72
  | `generateRandomDate()` | Random adult birthdate |
73
+ | `randomDateBetween(start,end)` | Date between two bounds |
70
74
  | `getAge(date)` | Age from birthdate |
71
75
  | `getContinent(code)` | Continent from country code |
72
76
  | `generatePreferences(categories,gender)` | Ad preference map |
73
- | `generateFakeProfile(params)` | Full profile JSON string |
77
+ | `generateFakeProfile(params)` | Full profile **object** (see `Profile` type) |
74
78
  | `generateFakeProfilesBatch(batchSize,params)` | Array of profiles |
75
- | `generateAndComposeCSV(total,batch,params)` | CSV string of profiles |
76
79
  | `composeCSVFile(data)` | Convert profiles to CSV |
80
+ | `generateAndComposeCSV(total,batch,params)` | CSV string of profiles |
77
81
  | `writeCSVFile(fname,content)` | Write CSV to disk |
78
82
 
79
- Refer to inline JSDoc and generated `.d.ts` for detailed types.
83
+ Refer to inline JSDoc and generated `.d.ts` for detailed types. The
84
+ package exports several interfaces (`Profile`, `Location`, `Passwords`, etc.)
85
+ for easier TypeScript consumption.
86
+
87
+ ---
88
+
89
+ ## Continuous integration
90
+
91
+ A GitHub Actions workflow (`.github/workflows/publish.yml`) builds the project
92
+ and publishes to npm when commits are pushed to `main`/`master` or a new
93
+ `vX.Y.Z` tag is created. A repository secret named `NPM_TOKEN` is required to
94
+ authenticate with npm.
95
+
96
+ > **npm warning**
97
+ > When the action runs, npm may auto‑correct issues in `package.json` (for
98
+ > example normalising `repository.url` to `git+…`). Run `npm pkg fix` locally
99
+ > or update the field manually to avoid the warnings.
100
+
101
+ GitHub Packages publishing is conditional on the package being scoped (e.g.
102
+ `@owner/name`); unscoped names are not allowed and will raise a 405 error.
103
+
104
+ ## Testing
105
+
106
+ A simple Jest setup lives under `tests/`. To run the tests:
107
+
108
+ ```bash
109
+ npm install # if dependencies changed
110
+ npm test
111
+ ```
112
+
113
+ This ensures future enhancements remain stable and provides examples of
114
+ utility usage.
80
115
 
81
116
  ## License
82
117