@carbon/cli 11.14.0-rc.0 → 11.15.0-rc.0
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/cli",
|
|
3
3
|
"description": "Task automation for working with the Carbon Design System",
|
|
4
|
-
"version": "11.
|
|
4
|
+
"version": "11.15.0-rc.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"bin": {
|
|
7
7
|
"carbon-cli": "./bin/carbon-cli.js"
|
|
@@ -51,7 +51,8 @@
|
|
|
51
51
|
"rollup": "^2.79.1",
|
|
52
52
|
"sass": "^1.51.0",
|
|
53
53
|
"sassdoc": "^2.7.3",
|
|
54
|
+
"typescript-config-carbon": "^0.2.0-rc.0",
|
|
54
55
|
"yargs": "^17.0.1"
|
|
55
56
|
},
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "da28d28a2d3a34503099e25255076efd3da4db9f"
|
|
57
58
|
}
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
10
|
const javascript = require('./javascript');
|
|
11
|
+
const typescript = require('./typescript');
|
|
11
12
|
|
|
12
|
-
const bundlers = new Map([
|
|
13
|
+
const bundlers = new Map([
|
|
14
|
+
['.js', javascript],
|
|
15
|
+
['.ts', typescript],
|
|
16
|
+
]);
|
|
13
17
|
|
|
14
18
|
module.exports = bundlers;
|
|
@@ -10,10 +10,14 @@
|
|
|
10
10
|
const { babel } = require('@rollup/plugin-babel');
|
|
11
11
|
const commonjs = require('@rollup/plugin-commonjs');
|
|
12
12
|
const { nodeResolve } = require('@rollup/plugin-node-resolve');
|
|
13
|
-
const { pascalCase } = require('change-case');
|
|
14
13
|
const fs = require('fs-extra');
|
|
15
14
|
const path = require('path');
|
|
16
15
|
const { rollup } = require('rollup');
|
|
16
|
+
const {
|
|
17
|
+
formatGlobals,
|
|
18
|
+
findPackageFolder,
|
|
19
|
+
formatDependenciesIntoGlobals,
|
|
20
|
+
} = require('./utils');
|
|
17
21
|
|
|
18
22
|
async function bundle(entrypoint, options) {
|
|
19
23
|
const globals = options.globals ? formatGlobals(options.globals) : {};
|
|
@@ -95,48 +99,4 @@ async function bundle(entrypoint, options) {
|
|
|
95
99
|
);
|
|
96
100
|
}
|
|
97
101
|
|
|
98
|
-
function formatGlobals(string) {
|
|
99
|
-
const mappings = string.split(',').map((mapping) => {
|
|
100
|
-
return mapping.split('=');
|
|
101
|
-
});
|
|
102
|
-
return mappings.reduce(
|
|
103
|
-
(acc, [pkg, global]) => ({
|
|
104
|
-
...acc,
|
|
105
|
-
[pkg]: global,
|
|
106
|
-
}),
|
|
107
|
-
{}
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function formatDependenciesIntoGlobals(dependencies) {
|
|
112
|
-
return Object.keys(dependencies).reduce((acc, key) => {
|
|
113
|
-
const parts = key.split('/').map((identifier, i) => {
|
|
114
|
-
if (i === 0) {
|
|
115
|
-
return identifier.replace(/@/, '');
|
|
116
|
-
}
|
|
117
|
-
return identifier;
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
return {
|
|
121
|
-
...acc,
|
|
122
|
-
[key]: pascalCase(parts.join(' ')),
|
|
123
|
-
};
|
|
124
|
-
}, {});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
async function findPackageFolder(entrypoint) {
|
|
128
|
-
let packageFolder = entrypoint;
|
|
129
|
-
|
|
130
|
-
while (packageFolder !== '/' && path.dirname(packageFolder) !== '/') {
|
|
131
|
-
packageFolder = path.dirname(packageFolder);
|
|
132
|
-
const packageJsonPath = path.join(packageFolder, 'package.json');
|
|
133
|
-
|
|
134
|
-
if (await fs.pathExists(packageJsonPath)) {
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return packageFolder;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
102
|
module.exports = bundle;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
const { babel } = require('@rollup/plugin-babel');
|
|
11
|
+
const commonjs = require('@rollup/plugin-commonjs');
|
|
12
|
+
const { nodeResolve } = require('@rollup/plugin-node-resolve');
|
|
13
|
+
const typescript = require('@rollup/plugin-typescript');
|
|
14
|
+
const fs = require('fs-extra');
|
|
15
|
+
const path = require('path');
|
|
16
|
+
const { rollup } = require('rollup');
|
|
17
|
+
const { loadBaseTsCompilerOpts } = require('typescript-config-carbon');
|
|
18
|
+
const {
|
|
19
|
+
formatGlobals,
|
|
20
|
+
findPackageFolder,
|
|
21
|
+
formatDependenciesIntoGlobals,
|
|
22
|
+
} = require('./utils');
|
|
23
|
+
|
|
24
|
+
async function bundle(entrypoint, options) {
|
|
25
|
+
const globals = options.globals ? formatGlobals(options.globals) : {};
|
|
26
|
+
const { name } = options;
|
|
27
|
+
const packageFolder = await findPackageFolder(entrypoint);
|
|
28
|
+
|
|
29
|
+
const outputFolders = [
|
|
30
|
+
{
|
|
31
|
+
format: 'esm',
|
|
32
|
+
directory: path.join(packageFolder, 'es'),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
format: 'cjs',
|
|
36
|
+
directory: path.join(packageFolder, 'lib'),
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
format: 'umd',
|
|
40
|
+
directory: path.join(packageFolder, 'umd'),
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
await Promise.all(outputFolders.map(({ directory }) => fs.remove(directory)));
|
|
45
|
+
|
|
46
|
+
const jsEntryPoints = outputFolders.map(({ directory, format }) => ({
|
|
47
|
+
outputDir: directory,
|
|
48
|
+
file: path.join(directory, 'index.js'),
|
|
49
|
+
format,
|
|
50
|
+
}));
|
|
51
|
+
|
|
52
|
+
const packageJsonPath = path.join(packageFolder, 'package.json');
|
|
53
|
+
const packageJson = await fs.readJson(packageJsonPath);
|
|
54
|
+
const { dependencies = {} } = packageJson;
|
|
55
|
+
|
|
56
|
+
const baseTsCompilerOpts = loadBaseTsCompilerOpts();
|
|
57
|
+
|
|
58
|
+
await Promise.all(
|
|
59
|
+
jsEntryPoints.map(async ({ outputDir, file, format }) => {
|
|
60
|
+
const bundle = await rollup({
|
|
61
|
+
input: entrypoint,
|
|
62
|
+
external: Object.keys(dependencies),
|
|
63
|
+
plugins: [
|
|
64
|
+
typescript({
|
|
65
|
+
noEmitOnError: true,
|
|
66
|
+
noForceEmit: true,
|
|
67
|
+
outputToFilesystem: false,
|
|
68
|
+
compilerOptions: {
|
|
69
|
+
...baseTsCompilerOpts,
|
|
70
|
+
rootDir: 'src',
|
|
71
|
+
outDir: outputDir,
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
|
+
babel({
|
|
75
|
+
exclude: 'node_modules/**',
|
|
76
|
+
babelrc: false,
|
|
77
|
+
presets: [
|
|
78
|
+
[
|
|
79
|
+
'@babel/preset-env',
|
|
80
|
+
{
|
|
81
|
+
modules: false,
|
|
82
|
+
targets: {
|
|
83
|
+
browsers: ['last 1 version', 'ie >= 11', 'Firefox ESR'],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
'@babel/preset-typescript',
|
|
88
|
+
],
|
|
89
|
+
babelHelpers: 'bundled',
|
|
90
|
+
extensions: ['.ts', '.tsx', '.js', '.jsx'],
|
|
91
|
+
}),
|
|
92
|
+
nodeResolve(),
|
|
93
|
+
commonjs({
|
|
94
|
+
include: [/node_modules/],
|
|
95
|
+
extensions: ['.js'],
|
|
96
|
+
}),
|
|
97
|
+
],
|
|
98
|
+
});
|
|
99
|
+
const outputOptions = {
|
|
100
|
+
exports: 'auto',
|
|
101
|
+
file,
|
|
102
|
+
format,
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
if (format === 'umd') {
|
|
106
|
+
outputOptions.name = name;
|
|
107
|
+
outputOptions.globals = {
|
|
108
|
+
...formatDependenciesIntoGlobals(dependencies),
|
|
109
|
+
...globals,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return bundle.write(outputOptions);
|
|
114
|
+
})
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
module.exports = bundle;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const fs = require('fs-extra');
|
|
12
|
+
const { pascalCase } = require('change-case');
|
|
13
|
+
|
|
14
|
+
function formatGlobals(string) {
|
|
15
|
+
const mappings = string.split(',').map((mapping) => {
|
|
16
|
+
return mapping.split('=');
|
|
17
|
+
});
|
|
18
|
+
return mappings.reduce(
|
|
19
|
+
(acc, [pkg, global]) => ({
|
|
20
|
+
...acc,
|
|
21
|
+
[pkg]: global,
|
|
22
|
+
}),
|
|
23
|
+
{}
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function formatDependenciesIntoGlobals(dependencies) {
|
|
28
|
+
return Object.keys(dependencies).reduce((acc, key) => {
|
|
29
|
+
const parts = key.split('/').map((identifier, i) => {
|
|
30
|
+
if (i === 0) {
|
|
31
|
+
return identifier.replace(/@/, '');
|
|
32
|
+
}
|
|
33
|
+
return identifier;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
...acc,
|
|
38
|
+
[key]: pascalCase(parts.join(' ')),
|
|
39
|
+
};
|
|
40
|
+
}, {});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function findPackageFolder(entrypoint) {
|
|
44
|
+
let packageFolder = entrypoint;
|
|
45
|
+
|
|
46
|
+
while (packageFolder !== '/' && path.dirname(packageFolder) !== '/') {
|
|
47
|
+
packageFolder = path.dirname(packageFolder);
|
|
48
|
+
const packageJsonPath = path.join(packageFolder, 'package.json');
|
|
49
|
+
|
|
50
|
+
if (await fs.pathExists(packageJsonPath)) {
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return packageFolder;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = {
|
|
59
|
+
formatGlobals,
|
|
60
|
+
formatDependenciesIntoGlobals,
|
|
61
|
+
findPackageFolder,
|
|
62
|
+
};
|