fabrique 0.2.0 → 0.2.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.
- package/.yarn/releases/yarn-4.6.0.cjs +934 -0
- package/.yarnrc.yml +2 -0
- package/README.md +2 -2
- package/package.json +7 -7
- package/src/actions/upgrade.js +1 -1
- package/templates/lib/.yarn/releases/yarn-4.6.0.cjs +934 -0
- package/templates/lib/.yarnrc.yml +2 -0
- package/templates/lib/CONTRIBUTING.md +7 -1
- package/templates/lib/fabrique/actions/build-and-publish.js +12 -0
- package/templates/lib/fabrique/actions/build.js +9 -15
- package/templates/lib/fabrique/actions/cli/build-and-publish.cli.js +14 -0
- package/templates/lib/fabrique/actions/cli/build.cli.js +14 -0
- package/templates/lib/fabrique/actions/cli/publish.cli.js +14 -0
- package/templates/lib/fabrique/actions/publish.js +61 -0
- package/templates/lib/fabrique/helpers/cmd.js +1 -0
- package/templates/lib/package.json +8 -7
- package/templates/lib/yarn.lock +1734 -0
|
@@ -35,6 +35,12 @@ yarn install
|
|
|
35
35
|
### Commands
|
|
36
36
|
|
|
37
37
|
- `fb:build`: builds the library.
|
|
38
|
+
- converts the typescript files into javascript files, copies the scss files, and assembles all the assets to create a package ready to be published.
|
|
38
39
|
- `fb:format`: formats the code using `prettier`.
|
|
39
40
|
- `fb:test`: runs the tests using `vitest`.
|
|
40
|
-
- `fb:
|
|
41
|
+
- `fb:prod`: builds the lib in `prod` mode.
|
|
42
|
+
- builds and publishes the lib on npm as a _prod_ version.
|
|
43
|
+
- `fb:dev`: builds the lib in `dev` .
|
|
44
|
+
- builds and publishes the lib on a local `verdaccio` with a `dev` tag.
|
|
45
|
+
- `fb:rc`: builds the lib in `rc` mode, and publishes it on a local `verdaccio`.
|
|
46
|
+
- builds and publishes the lib on npm with a `rc` tag.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { build } from './build.js';
|
|
2
|
+
import { publish } from './publish.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Builds the lib.
|
|
6
|
+
* @param {{ mode?: 'dev' | 'rc' | 'prod' }} options
|
|
7
|
+
* @return {Promise<void>}
|
|
8
|
+
*/
|
|
9
|
+
export async function buildAndPublish(options) {
|
|
10
|
+
await build(options);
|
|
11
|
+
await publish(options);
|
|
12
|
+
}
|
|
@@ -4,10 +4,10 @@ import { cmd } from '../helpers/cmd.js';
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Builds the lib.
|
|
7
|
-
* @param {{
|
|
7
|
+
* @param {{ mode?: 'dev' | 'rc' | 'prod' }} options
|
|
8
8
|
* @return {Promise<void>}
|
|
9
9
|
*/
|
|
10
|
-
async function build({
|
|
10
|
+
export async function build({ mode = 'prod' } = {}) {
|
|
11
11
|
const rootPath = '.';
|
|
12
12
|
const sourcePath = './src';
|
|
13
13
|
const destinationPath = './dist';
|
|
@@ -22,7 +22,7 @@ async function build({ dev = false } = {}) {
|
|
|
22
22
|
]);
|
|
23
23
|
|
|
24
24
|
await buildPackageJsonFile(destinationPath, {
|
|
25
|
-
|
|
25
|
+
mode,
|
|
26
26
|
withProtected,
|
|
27
27
|
});
|
|
28
28
|
} catch (error) {
|
|
@@ -103,7 +103,7 @@ async function buildTypescriptIndexFile(cwd = process.cwd()) {
|
|
|
103
103
|
)
|
|
104
104
|
)
|
|
105
105
|
.map((path) => {
|
|
106
|
-
return `export * from './${path.slice(0, -3)}.js';`;
|
|
106
|
+
return `export * from './${path.replaceAll('\\', '/').slice(0, -3)}.js';`;
|
|
107
107
|
})
|
|
108
108
|
.join('\n');
|
|
109
109
|
|
|
@@ -139,7 +139,7 @@ async function buildTypescriptProtectedIndexFile(cwd = process.cwd()) {
|
|
|
139
139
|
)
|
|
140
140
|
)
|
|
141
141
|
.map((path) => {
|
|
142
|
-
return `export * from './${path.slice(0, -3)}.js';`;
|
|
142
|
+
return `export * from './${path.replaceAll('\\', '/').slice(0, -3)}.js';`;
|
|
143
143
|
})
|
|
144
144
|
.join('\n');
|
|
145
145
|
|
|
@@ -304,12 +304,12 @@ async function removeTypescriptIndexFile(indexFilePath) {
|
|
|
304
304
|
* Generates the package.json to publish.
|
|
305
305
|
*
|
|
306
306
|
* @param {string} destinationPath
|
|
307
|
-
* @param {{ cwd?: string;
|
|
307
|
+
* @param {{ cwd?: string; mode?: 'dev' | 'rc' | 'prod', withProtected?: boolean }} options
|
|
308
308
|
* @return {Promise<void>}
|
|
309
309
|
*/
|
|
310
310
|
async function buildPackageJsonFile(
|
|
311
311
|
destinationPath,
|
|
312
|
-
{ cwd = process.cwd(),
|
|
312
|
+
{ cwd = process.cwd(), mode = 'prod', withProtected = false } = {},
|
|
313
313
|
) {
|
|
314
314
|
console.log('Building package.json...');
|
|
315
315
|
|
|
@@ -322,8 +322,8 @@ async function buildPackageJsonFile(
|
|
|
322
322
|
|
|
323
323
|
const indexTypesPath = './index.d.ts';
|
|
324
324
|
|
|
325
|
-
if (
|
|
326
|
-
pkg.version +=
|
|
325
|
+
if (mode !== 'prod') {
|
|
326
|
+
pkg.version += `-${mode}.${Date.now()}`;
|
|
327
327
|
}
|
|
328
328
|
|
|
329
329
|
Object.assign(pkg, {
|
|
@@ -347,9 +347,3 @@ async function buildPackageJsonFile(
|
|
|
347
347
|
|
|
348
348
|
await writeFile(join(destinationPath, fileName), JSON.stringify(pkg, null, 2));
|
|
349
349
|
}
|
|
350
|
-
|
|
351
|
-
/*-----------------------------------*/
|
|
352
|
-
|
|
353
|
-
const [dev = false] = process.argv.slice(2);
|
|
354
|
-
|
|
355
|
-
build({ dev });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { buildAndPublish } from '../build-and-publish.js';
|
|
3
|
+
|
|
4
|
+
const { values } = parseArgs({
|
|
5
|
+
options: {
|
|
6
|
+
mode: {
|
|
7
|
+
type: 'string',
|
|
8
|
+
short: 'm',
|
|
9
|
+
default: 'prod',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
buildAndPublish(values);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { cmd } from '../helpers/cmd.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Published the lib.
|
|
6
|
+
* @param {{ mode?: 'dev' | 'rc' | 'prod'; }} options
|
|
7
|
+
* @return {Promise<void>}
|
|
8
|
+
*/
|
|
9
|
+
export async function publish({ mode = 'prod' } = {}) {
|
|
10
|
+
const packagePath = './dist';
|
|
11
|
+
|
|
12
|
+
console.log('Publishing library...');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @type {{
|
|
16
|
+
* quiet?: boolean;
|
|
17
|
+
* registry?: string;
|
|
18
|
+
* access?: 'public';
|
|
19
|
+
* tag?: string;
|
|
20
|
+
* }}
|
|
21
|
+
*/
|
|
22
|
+
const options = {};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @type {string[]}
|
|
26
|
+
*/
|
|
27
|
+
const args = ['publish'];
|
|
28
|
+
|
|
29
|
+
if (mode === 'dev') {
|
|
30
|
+
options.quiet = true;
|
|
31
|
+
options.registry = 'http://localhost:4873';
|
|
32
|
+
options.tag = 'dev';
|
|
33
|
+
} else {
|
|
34
|
+
options.registry = 'https://registry.npmjs.org';
|
|
35
|
+
options.access = 'public';
|
|
36
|
+
|
|
37
|
+
if (mode === 'rc') {
|
|
38
|
+
options.tag = 'rc';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (options.quiet) {
|
|
43
|
+
args.push('--quiet');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (options.registry) {
|
|
47
|
+
args.push('--registry', options.registry);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (options.access) {
|
|
51
|
+
args.push('--access', options.access);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (options.tag) {
|
|
55
|
+
args.push('--tag', options.tag);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
await cmd('npm', args, { cwd: join(process.cwd(), packagePath) });
|
|
59
|
+
|
|
60
|
+
console.log('Library published with success !');
|
|
61
|
+
}
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"fb:build": "node fabrique/actions/build.js",
|
|
7
|
+
"fb:build": "node fabrique/actions/cli/build.cli.js",
|
|
8
8
|
"fb:format": "prettier --write --ignore-unknown --config ./.prettierrc \"src/**/*.{js,jsx,ts,tsx,html,css,scss}\"",
|
|
9
9
|
"fb:test": "vitest",
|
|
10
10
|
"fb:test:coverage": "vitest run --coverage",
|
|
11
|
-
"fb:prod": "node fabrique/actions/build.js
|
|
12
|
-
"fb:dev": "node fabrique/actions/build.js --dev
|
|
11
|
+
"fb:prod": "node fabrique/actions/cli/build-and-publish.cli.js --mode prod",
|
|
12
|
+
"fb:dev": "node fabrique/actions/cli/build-and-publish.cli.js --mode dev",
|
|
13
|
+
"fb:rc": "node fabrique/actions/cli/build-and-publish.cli.js --mode rc"
|
|
13
14
|
},
|
|
14
15
|
"description": "{{description}}",
|
|
15
16
|
"keywords": [],
|
|
@@ -21,10 +22,10 @@
|
|
|
21
22
|
"url": "{{giturl}}"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
|
-
"prettier": "^3.
|
|
25
|
+
"prettier": "^3.4.2",
|
|
25
26
|
"prettier-plugin-organize-imports": "^4.1.0",
|
|
26
|
-
"typescript": "^5.
|
|
27
|
-
"vitest": "^2.1.
|
|
27
|
+
"typescript": "^5.7.2",
|
|
28
|
+
"vitest": "^2.1.8"
|
|
28
29
|
},
|
|
29
|
-
"packageManager": "yarn@4.
|
|
30
|
+
"packageManager": "yarn@4.6.0"
|
|
30
31
|
}
|