create-react-native-library 0.57.2 → 0.58.1

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.
Files changed (49) hide show
  1. package/lib/constants.js +4 -3
  2. package/lib/constants.js.map +1 -1
  3. package/lib/exampleApp/generateExampleApp.js +18 -13
  4. package/lib/exampleApp/generateExampleApp.js.map +1 -1
  5. package/lib/inform.js +1 -1
  6. package/lib/inform.js.map +1 -1
  7. package/lib/prompt.js +21 -10
  8. package/lib/prompt.js.map +1 -1
  9. package/lib/template.js +34 -5
  10. package/lib/template.js.map +1 -1
  11. package/lib/utils/configureTools.js +73 -105
  12. package/lib/utils/configureTools.js.map +1 -1
  13. package/package.json +22 -22
  14. package/templates/common/$.github/workflows/ci.yml +6 -4
  15. package/templates/common/$package.json +4 -4
  16. package/templates/common/CONTRIBUTING.md +9 -5
  17. package/templates/common/README.md +1 -11
  18. package/templates/js-library/src/index.tsx +1 -3
  19. package/templates/js-library/src/multiply.tsx +3 -0
  20. package/templates/js-view/src/index.tsx +1 -0
  21. package/templates/js-view/src/{%- project.name %}View.tsx +9 -0
  22. package/templates/native-library-new/src/index.tsx +1 -5
  23. package/templates/native-library-new/src/multiply.native.tsx +5 -0
  24. package/templates/native-library-new/src/multiply.tsx +5 -0
  25. package/templates/native-view-new/src/index.tsx +1 -2
  26. package/templates/native-view-new/src/{%- project.name %}View.native.tsx +2 -0
  27. package/templates/native-view-new/src/{%- project.name %}View.tsx +11 -0
  28. package/templates/nitro-common/nitro.json +8 -2
  29. package/templates/nitro-module/src/index.tsx +1 -9
  30. package/templates/nitro-module/src/multiply.native.tsx +9 -0
  31. package/templates/nitro-module/src/multiply.tsx +5 -0
  32. package/templates/nitro-module/src/{%- project.name %}.nitro.ts +4 -2
  33. package/templates/nitro-view/src/index.tsx +1 -11
  34. package/templates/nitro-view/src/{%- project.name %}View.native.tsx +11 -0
  35. package/templates/nitro-view/src/{%- project.name %}View.tsx +11 -0
  36. package/templates/tools/eslint/~package.json +23 -0
  37. package/templates/tools/jest/src/__tests__/index.test.tsx +2 -0
  38. package/templates/tools/jest/~package.json +16 -0
  39. package/templates/tools/lefthook/~package.json +10 -0
  40. package/templates/tools/release-it/~package.json +28 -0
  41. package/templates/tools/turborepo/~package.json +5 -0
  42. package/templates/tools/vite/example/index.html +25 -0
  43. package/templates/tools/vite/example/index.js +11 -0
  44. package/templates/tools/vite/example/vite.config.mjs +15 -0
  45. package/templates/tools/vite/example/~package.json +14 -0
  46. package/templates/tools/vite/~package.json +9 -0
  47. /package/templates/{native-common-example → example-bare}/example/babel.config.js +0 -0
  48. /package/templates/{native-common-example → example-bare}/example/index.js +0 -0
  49. /package/templates/{native-common-example → example-native-common}/example/react-native.config.js +0 -0
@@ -9,113 +9,60 @@ var _fsExtra = _interopRequireDefault(require("fs-extra"));
9
9
  var _nodePath = _interopRequireDefault(require("node:path"));
10
10
  var _template = require("../template");
11
11
  var _sortObjectKeys = _interopRequireDefault(require("./sortObjectKeys"));
12
- var _constants = require("../constants");
13
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
13
  const ESLINT = {
15
14
  name: 'ESLint with Prettier',
16
- description: 'Lint and format code',
17
- package: {
18
- scripts: {
19
- lint: 'eslint "**/*.{js,ts,tsx}"'
20
- },
21
- prettier: {
22
- quoteProps: 'consistent',
23
- singleQuote: true,
24
- tabWidth: 2,
25
- trailingComma: 'es5',
26
- useTabs: false
27
- },
28
- devDependencies: {
29
- '@eslint/compat': '^1.3.2',
30
- '@eslint/eslintrc': '^3.3.1',
31
- '@eslint/js': '^9.35.0',
32
- '@react-native/eslint-config': _constants.SUPPORTED_REACT_NATIVE_VERSION,
33
- 'eslint-config-prettier': '^10.1.8',
34
- 'eslint-plugin-prettier': '^5.5.4',
35
- 'eslint': '^9.35.0',
36
- 'prettier': '^2.8.8'
37
- }
38
- }
15
+ description: 'Lint and format code'
39
16
  };
40
17
  const LEFTHOOK = {
41
18
  name: 'Lefthook with Commitlint',
42
- description: 'Manage Git hooks and lint commit messages',
43
- package: {
44
- commitlint: {
45
- extends: ['@commitlint/config-conventional']
46
- },
47
- devDependencies: {
48
- '@commitlint/config-conventional': '^19.8.1',
49
- 'commitlint': '^19.8.1',
50
- 'lefthook': '^2.0.3'
51
- }
52
- }
19
+ description: 'Manage Git hooks and lint commit messages'
53
20
  };
54
21
  const RELEASE_IT = {
55
22
  name: 'Release It',
56
- description: 'Automate versioning and package publishing tasks',
57
- package: {
58
- 'scripts': {
59
- release: 'release-it --only-version'
60
- },
61
- 'release-it': {
62
- git: {
63
- // eslint-disable-next-line no-template-curly-in-string
64
- commitMessage: 'chore: release ${version}',
65
- // eslint-disable-next-line no-template-curly-in-string
66
- tagName: 'v${version}'
67
- },
68
- npm: {
69
- publish: true
70
- },
71
- github: {
72
- release: true
73
- },
74
- plugins: {
75
- '@release-it/conventional-changelog': {
76
- preset: {
77
- name: 'angular'
78
- }
79
- }
80
- }
81
- },
82
- 'devDependencies': {
83
- 'release-it': '^19.0.4',
84
- '@release-it/conventional-changelog': '^10.0.1'
85
- }
86
- }
23
+ description: 'Automate versioning and package publishing tasks'
87
24
  };
88
25
  const JEST = {
89
26
  name: 'Jest',
90
- description: 'Test JavaScript and TypeScript code',
91
- package: {
92
- scripts: {
93
- test: 'jest'
94
- },
95
- jest: {
96
- preset: 'react-native',
97
- modulePathIgnorePatterns: ['<rootDir>/example/node_modules', '<rootDir>/lib/']
98
- },
99
- devDependencies: {
100
- '@types/jest': '^29.5.14',
101
- 'jest': '^29.7.0'
102
- }
103
- }
27
+ description: 'Test JavaScript and TypeScript code'
104
28
  };
105
29
  const TURBOREPO = {
106
30
  name: 'Turborepo',
107
- description: 'Cache build outputs on CI',
108
- package: {
109
- devDependencies: {
110
- turbo: '^2.5.6'
31
+ description: 'Cache build outputs on CI'
32
+ };
33
+ const VITE = {
34
+ name: 'Vite',
35
+ description: 'Add web support to the example app',
36
+ condition: config => config.example != null && config.example !== 'expo',
37
+ postprocess: async ({
38
+ root
39
+ }) => {
40
+ const examplePkgPath = _nodePath.default.join(root, 'example', 'package.json');
41
+ if (!_fsExtra.default.existsSync(examplePkgPath)) {
42
+ throw new Error("Couldn't find the example app's package.json.");
43
+ }
44
+
45
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
46
+ const examplePackageJson = await _fsExtra.default.readJson(examplePkgPath);
47
+ const reactVersion = examplePackageJson.dependencies?.react ?? examplePackageJson.devDependencies?.react;
48
+ if (reactVersion == null) {
49
+ throw new Error("Couldn't find the package 'react' in the example app.");
111
50
  }
51
+ examplePackageJson.dependencies = (0, _sortObjectKeys.default)({
52
+ ...examplePackageJson.dependencies,
53
+ 'react-dom': reactVersion
54
+ });
55
+ await _fsExtra.default.writeJson(examplePkgPath, examplePackageJson, {
56
+ spaces: 2
57
+ });
112
58
  }
113
59
  };
114
60
  const AVAILABLE_TOOLS = exports.AVAILABLE_TOOLS = {
115
- 'eslint': ESLINT,
116
- 'jest': JEST,
117
- 'lefthook': LEFTHOOK,
118
- 'release-it': RELEASE_IT
61
+ eslint: ESLINT,
62
+ jest: JEST,
63
+ lefthook: LEFTHOOK,
64
+ 'release-it': RELEASE_IT,
65
+ vite: VITE
119
66
  };
120
67
  const REQUIRED_TOOLS = {
121
68
  turborepo: TURBOREPO
@@ -142,27 +89,48 @@ async function configureTools({
142
89
  if (tool.condition && !tool.condition(config)) {
143
90
  continue;
144
91
  }
145
- const files = _nodePath.default.resolve(__dirname, `../../templates/tools/${key}`);
146
- if (_fsExtra.default.existsSync(files)) {
147
- await (0, _template.applyTemplate)(config, files, root);
92
+ const toolDir = _nodePath.default.resolve(__dirname, `../../templates/tools/${key}`);
93
+ if (_fsExtra.default.existsSync(toolDir)) {
94
+ await (0, _template.applyTemplate)(config, toolDir, root);
148
95
  }
149
- for (const [key, value] of Object.entries(tool.package)) {
150
- if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
151
- if (typeof packageJson[key] === 'object' || packageJson[key] == null) {
152
- packageJson[key] = {
153
- ...packageJson[key],
154
- ...value
155
- };
156
- if (key === 'dependencies' || key === 'devDependencies' || key === 'peerDependencies') {
157
- // @ts-expect-error: We know they are objects here
158
- packageJson[key] = (0, _sortObjectKeys.default)(packageJson[key]);
159
- }
160
- } else {
161
- throw new Error(`Cannot merge '${key}' field because it is not an object (got '${String(packageJson[key])}').`);
96
+ const examplePkgPath = _nodePath.default.join(toolDir, 'example', '~package.json');
97
+ await mergePackageJsonTemplate(_nodePath.default.join(toolDir, '~package.json'), packageJson);
98
+ if (_fsExtra.default.existsSync(examplePkgPath)) {
99
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
100
+ const existingExamplePackageJson = await _fsExtra.default.readJson(_nodePath.default.join(root, 'example', 'package.json'));
101
+ await mergePackageJsonTemplate(examplePkgPath, existingExamplePackageJson);
102
+ await _fsExtra.default.writeJson(_nodePath.default.join(root, 'example', 'package.json'), existingExamplePackageJson, {
103
+ spaces: 2
104
+ });
105
+ }
106
+ await tool.postprocess?.({
107
+ config,
108
+ root
109
+ });
110
+ }
111
+ }
112
+ async function mergePackageJsonTemplate(templatePath, packageJson) {
113
+ if (!_fsExtra.default.existsSync(templatePath)) {
114
+ return;
115
+ }
116
+
117
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
118
+ const template = await _fsExtra.default.readJson(templatePath);
119
+ for (const [field, value] of Object.entries(template)) {
120
+ if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
121
+ if (typeof packageJson[field] === 'object' || packageJson[field] == null) {
122
+ packageJson[field] = {
123
+ ...packageJson[field],
124
+ ...value
125
+ };
126
+ if (field === 'dependencies' || field === 'devDependencies' || field === 'peerDependencies') {
127
+ packageJson[field] = (0, _sortObjectKeys.default)(packageJson[field]);
162
128
  }
163
129
  } else {
164
- packageJson[key] = value;
130
+ throw new Error(`Cannot merge '${field}' field because it is not an object (got '${String(packageJson[field])}').`);
165
131
  }
132
+ } else {
133
+ packageJson[field] = value;
166
134
  }
167
135
  }
168
136
  }
@@ -1 +1 @@
1
- {"version":3,"file":"configureTools.js","names":["_fsExtra","_interopRequireDefault","require","_nodePath","_template","_sortObjectKeys","_constants","e","__esModule","default","ESLINT","name","description","package","scripts","lint","prettier","quoteProps","singleQuote","tabWidth","trailingComma","useTabs","devDependencies","SUPPORTED_REACT_NATIVE_VERSION","LEFTHOOK","commitlint","extends","RELEASE_IT","release","git","commitMessage","tagName","npm","publish","github","plugins","preset","JEST","test","jest","modulePathIgnorePatterns","TURBOREPO","turbo","AVAILABLE_TOOLS","exports","REQUIRED_TOOLS","turborepo","ALL_TOOLS","configureTools","tools","config","root","packageJson","key","Object","keys","Error","join","tool","condition","files","path","resolve","__dirname","fs","existsSync","applyTemplate","value","entries","Array","isArray","sortObjectKeys","String"],"sources":["../../src/utils/configureTools.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport path from 'node:path';\nimport { applyTemplate, type TemplateConfiguration } from '../template';\nimport sortObjectKeys from './sortObjectKeys';\nimport { SUPPORTED_REACT_NATIVE_VERSION } from '../constants';\n\ntype Tool = {\n name: string;\n description: string;\n package: Record<string, unknown>;\n condition?: (config: TemplateConfiguration) => boolean;\n};\n\ntype Options = {\n tools: string[];\n root: string;\n packageJson: Record<string, unknown>;\n config: TemplateConfiguration;\n};\n\nconst ESLINT = {\n name: 'ESLint with Prettier',\n description: 'Lint and format code',\n package: {\n scripts: {\n lint: 'eslint \"**/*.{js,ts,tsx}\"',\n },\n prettier: {\n quoteProps: 'consistent',\n singleQuote: true,\n tabWidth: 2,\n trailingComma: 'es5',\n useTabs: false,\n },\n devDependencies: {\n '@eslint/compat': '^1.3.2',\n '@eslint/eslintrc': '^3.3.1',\n '@eslint/js': '^9.35.0',\n '@react-native/eslint-config': SUPPORTED_REACT_NATIVE_VERSION,\n 'eslint-config-prettier': '^10.1.8',\n 'eslint-plugin-prettier': '^5.5.4',\n 'eslint': '^9.35.0',\n 'prettier': '^2.8.8',\n },\n },\n};\n\nconst LEFTHOOK = {\n name: 'Lefthook with Commitlint',\n description: 'Manage Git hooks and lint commit messages',\n package: {\n commitlint: {\n extends: ['@commitlint/config-conventional'],\n },\n devDependencies: {\n '@commitlint/config-conventional': '^19.8.1',\n 'commitlint': '^19.8.1',\n 'lefthook': '^2.0.3',\n },\n },\n};\n\nconst RELEASE_IT = {\n name: 'Release It',\n description: 'Automate versioning and package publishing tasks',\n package: {\n 'scripts': {\n release: 'release-it --only-version',\n },\n 'release-it': {\n git: {\n // eslint-disable-next-line no-template-curly-in-string\n commitMessage: 'chore: release ${version}',\n // eslint-disable-next-line no-template-curly-in-string\n tagName: 'v${version}',\n },\n npm: {\n publish: true,\n },\n github: {\n release: true,\n },\n plugins: {\n '@release-it/conventional-changelog': {\n preset: {\n name: 'angular',\n },\n },\n },\n },\n 'devDependencies': {\n 'release-it': '^19.0.4',\n '@release-it/conventional-changelog': '^10.0.1',\n },\n },\n};\n\nconst JEST = {\n name: 'Jest',\n description: 'Test JavaScript and TypeScript code',\n package: {\n scripts: {\n test: 'jest',\n },\n jest: {\n preset: 'react-native',\n modulePathIgnorePatterns: [\n '<rootDir>/example/node_modules',\n '<rootDir>/lib/',\n ],\n },\n devDependencies: {\n '@types/jest': '^29.5.14',\n 'jest': '^29.7.0',\n },\n },\n};\n\nconst TURBOREPO = {\n name: 'Turborepo',\n description: 'Cache build outputs on CI',\n package: {\n devDependencies: {\n turbo: '^2.5.6',\n },\n },\n};\n\nexport const AVAILABLE_TOOLS = {\n 'eslint': ESLINT,\n 'jest': JEST,\n 'lefthook': LEFTHOOK,\n 'release-it': RELEASE_IT,\n} as const satisfies Record<string, Tool>;\n\nconst REQUIRED_TOOLS = {\n turborepo: TURBOREPO,\n} as const satisfies Record<string, Tool>;\n\nconst ALL_TOOLS = {\n ...AVAILABLE_TOOLS,\n ...REQUIRED_TOOLS,\n} as const;\n\nexport async function configureTools({\n tools,\n config,\n root,\n packageJson,\n}: Options) {\n for (const key of [\n ...tools,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion\n ...(Object.keys(REQUIRED_TOOLS) as (keyof typeof REQUIRED_TOOLS)[]),\n ]) {\n if (!(key in ALL_TOOLS)) {\n throw new Error(\n `Invalid tool '${key}'. Available tools are: ${Object.keys(\n AVAILABLE_TOOLS\n ).join(', ')}.`\n );\n }\n\n // @ts-expect-error: We checked the key above\n const tool: Tool = ALL_TOOLS[key];\n\n if (tool.condition && !tool.condition(config)) {\n continue;\n }\n\n const files = path.resolve(__dirname, `../../templates/tools/${key}`);\n\n if (fs.existsSync(files)) {\n await applyTemplate(config, files, root);\n }\n\n for (const [key, value] of Object.entries(tool.package)) {\n if (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value)\n ) {\n if (typeof packageJson[key] === 'object' || packageJson[key] == null) {\n packageJson[key] = {\n ...packageJson[key],\n ...value,\n };\n\n if (\n key === 'dependencies' ||\n key === 'devDependencies' ||\n key === 'peerDependencies'\n ) {\n // @ts-expect-error: We know they are objects here\n packageJson[key] = sortObjectKeys(packageJson[key]);\n }\n } else {\n throw new Error(\n `Cannot merge '${key}' field because it is not an object (got '${String(packageJson[key])}').`\n );\n }\n } else {\n packageJson[key] = value;\n }\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAA8D,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAgB9D,MAAMG,MAAM,GAAG;EACbC,IAAI,EAAE,sBAAsB;EAC5BC,WAAW,EAAE,sBAAsB;EACnCC,OAAO,EAAE;IACPC,OAAO,EAAE;MACPC,IAAI,EAAE;IACR,CAAC;IACDC,QAAQ,EAA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ACC,SAAS,CAACT,MAAM,CAAC,EAAE;MAC7C;IACF;IAEA,MAAMU,KAAK,GAAGC,iBAAI,CAACC,OAAO,CAACC,SAAS,EAAE,yBAAyBV,GAAG,EAAE,CAAC;IAErE,IAAIW,gBAAE,CAACC,UAAU,CAACL,KAAK,CAAC,EAAE;MACxB,MAAM,IAAAM,uBAAa,EAAChB,MAAM,EAAEU,KAAK,EAAET,IAAI,CAAC;IAC1C;IAEA,KAAK,MAAM,CAACE,GAAG,EAAEc,KAAK,CAAC,IAAIb,MAAM,CAACc,OAAO,CAACV,IAAI,CAAC7C,OAAO,CAAC,EAAE;MACvD,IACE,OAAOsD,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACd,CAACE,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EACrB;QACA,IAAI,OAAOf,WAAW,CAACC,GAAG,CAAC,KAAK,QAAQ,IAAID,WAAW,CAACC,GAAG,CAAC,IAAI,IAAI,EAAE;UACpED,WAAW,CAACC,GAAG,CAAC,GAAG;YACjB,GAAGD,WAAW,CAACC,GAAG,CAAC;YACnB,GAAGc;UACL,CAAC;UAED,IACEd,GAAG,KAAK,cAAc,IACtBA,GAAG,KAAK,iBAAiB,IACzBA,GAAG,KAAK,kBAAkB,EAC1B;YACA;YACAD,WAAW,CAACC,GAAG,CAAC,GAAG,IAAAkB,uBAAc,EAACnB,WAAW,CAACC,GAAG,CAAC,CAAC;UACrD;QACF,CAAC,MAAM;UACL,MAAM,IAAIG,KAAK,CACb,iBAAiBH,GAAG,6CAA6CmB,MAAM,CAACpB,WAAW,CAACC,GAAG,CAAC,CAAC,KAC3F,CAAC;QACH;MACF,CAAC,MAAM;QACLD,WAAW,CAACC,GAAG,CAAC,GAAGc,KAAK;MAC1B;IACF;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"configureTools.js","names":["_fsExtra","_interopRequireDefault","require","_nodePath","_template","_sortObjectKeys","e","__esModule","default","ESLINT","name","description","LEFTHOOK","RELEASE_IT","JEST","TURBOREPO","VITE","condition","config","example","postprocess","root","examplePkgPath","path","join","fs","existsSync","Error","examplePackageJson","readJson","reactVersion","dependencies","react","devDependencies","sortObjectKeys","writeJson","spaces","AVAILABLE_TOOLS","exports","eslint","jest","lefthook","vite","REQUIRED_TOOLS","turborepo","ALL_TOOLS","configureTools","tools","packageJson","key","Object","keys","tool","toolDir","resolve","__dirname","applyTemplate","mergePackageJsonTemplate","existingExamplePackageJson","templatePath","template","field","value","entries","Array","isArray","String"],"sources":["../../src/utils/configureTools.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport path from 'node:path';\nimport { applyTemplate, type TemplateConfiguration } from '../template';\nimport sortObjectKeys from './sortObjectKeys';\n\ntype PackageJson = {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n [key: string]: unknown;\n};\n\ntype Tool = {\n name: string;\n description: string;\n condition?: (context: Pick<TemplateConfiguration, 'example'>) => boolean;\n postprocess?: (options: {\n config: TemplateConfiguration;\n root: string;\n }) => void | Promise<void>;\n};\n\ntype Options = {\n tools: string[];\n root: string;\n packageJson: PackageJson;\n config: TemplateConfiguration;\n};\n\nconst ESLINT = {\n name: 'ESLint with Prettier',\n description: 'Lint and format code',\n};\n\nconst LEFTHOOK = {\n name: 'Lefthook with Commitlint',\n description: 'Manage Git hooks and lint commit messages',\n};\n\nconst RELEASE_IT = {\n name: 'Release It',\n description: 'Automate versioning and package publishing tasks',\n};\n\nconst JEST = {\n name: 'Jest',\n description: 'Test JavaScript and TypeScript code',\n};\n\nconst TURBOREPO = {\n name: 'Turborepo',\n description: 'Cache build outputs on CI',\n};\n\nconst VITE: Tool = {\n name: 'Vite',\n description: 'Add web support to the example app',\n condition: (config) => config.example != null && config.example !== 'expo',\n postprocess: async ({ root }) => {\n const examplePkgPath = path.join(root, 'example', 'package.json');\n\n if (!fs.existsSync(examplePkgPath)) {\n throw new Error(\"Couldn't find the example app's package.json.\");\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion\n const examplePackageJson = (await fs.readJson(\n examplePkgPath\n )) as PackageJson;\n\n const reactVersion =\n examplePackageJson.dependencies?.react ??\n examplePackageJson.devDependencies?.react;\n\n if (reactVersion == null) {\n throw new Error(\"Couldn't find the package 'react' in the example app.\");\n }\n\n examplePackageJson.dependencies = sortObjectKeys({\n ...examplePackageJson.dependencies,\n 'react-dom': reactVersion,\n });\n\n await fs.writeJson(examplePkgPath, examplePackageJson, { spaces: 2 });\n },\n};\n\nexport const AVAILABLE_TOOLS = {\n eslint: ESLINT,\n jest: JEST,\n lefthook: LEFTHOOK,\n 'release-it': RELEASE_IT,\n vite: VITE,\n} as const satisfies Record<string, Tool>;\n\nconst REQUIRED_TOOLS = {\n turborepo: TURBOREPO,\n} as const satisfies Record<string, Tool>;\n\nconst ALL_TOOLS = {\n ...AVAILABLE_TOOLS,\n ...REQUIRED_TOOLS,\n} as const;\n\nexport async function configureTools({\n tools,\n config,\n root,\n packageJson,\n}: Options) {\n for (const key of [\n ...tools,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion\n ...(Object.keys(REQUIRED_TOOLS) as (keyof typeof REQUIRED_TOOLS)[]),\n ]) {\n if (!(key in ALL_TOOLS)) {\n throw new Error(\n `Invalid tool '${key}'. Available tools are: ${Object.keys(\n AVAILABLE_TOOLS\n ).join(', ')}.`\n );\n }\n\n // @ts-expect-error: We checked the key above\n const tool: Tool = ALL_TOOLS[key];\n\n if (tool.condition && !tool.condition(config)) {\n continue;\n }\n\n const toolDir = path.resolve(__dirname, `../../templates/tools/${key}`);\n\n if (fs.existsSync(toolDir)) {\n await applyTemplate(config, toolDir, root);\n }\n\n const examplePkgPath = path.join(toolDir, 'example', '~package.json');\n\n await mergePackageJsonTemplate(\n path.join(toolDir, '~package.json'),\n packageJson\n );\n\n if (fs.existsSync(examplePkgPath)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion\n const existingExamplePackageJson = (await fs.readJson(\n path.join(root, 'example', 'package.json')\n )) as PackageJson;\n\n await mergePackageJsonTemplate(\n examplePkgPath,\n existingExamplePackageJson\n );\n\n await fs.writeJson(\n path.join(root, 'example', 'package.json'),\n existingExamplePackageJson,\n {\n spaces: 2,\n }\n );\n }\n\n await tool.postprocess?.({ config, root });\n }\n}\n\nasync function mergePackageJsonTemplate(\n templatePath: string,\n packageJson: PackageJson\n) {\n if (!fs.existsSync(templatePath)) {\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion\n const template = (await fs.readJson(templatePath)) as PackageJson;\n\n for (const [field, value] of Object.entries(template)) {\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n if (\n typeof packageJson[field] === 'object' ||\n packageJson[field] == null\n ) {\n packageJson[field] = {\n ...packageJson[field],\n ...value,\n };\n\n if (\n field === 'dependencies' ||\n field === 'devDependencies' ||\n field === 'peerDependencies'\n ) {\n packageJson[field] = sortObjectKeys(packageJson[field]);\n }\n } else {\n throw new Error(\n `Cannot merge '${field}' field because it is not an object (got '${String(packageJson[field])}').`\n );\n }\n } else {\n packageJson[field] = value;\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AA0B9C,MAAMG,MAAM,GAAG;EACbC,IAAI,EAAE,sBAAsB;EAC5BC,WAAW,EAAE;AACf,CAAC;AAED,MAAMC,QAAQ,GAAG;EACfF,IAAI,EAAE,0BAA0B;EAChCC,WAAW,EAAE;AACf,CAAC;AAED,MAAME,UAAU,GAAG;EACjBH,IAAI,EAAE,YAAY;EAClBC,WAA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5B;UACAb,WAAW,CAACa,KAAK,CAAC,GAAG,IAAA3B,uBAAc,EAACc,WAAW,CAACa,KAAK,CAAC,CAAC;QACzD;MACF,CAAC,MAAM;QACL,MAAM,IAAIlC,KAAK,CACb,iBAAiBkC,KAAK,6CAA6CK,MAAM,CAAClB,WAAW,CAACa,KAAK,CAAC,CAAC,KAC/F,CAAC;MACH;IACF,CAAC,MAAM;MACLb,WAAW,CAACa,KAAK,CAAC,GAAGC,KAAK;IAC5B;EACF;AACF","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-react-native-library",
3
- "version": "0.57.2",
3
+ "version": "0.58.1",
4
4
  "description": "CLI to scaffold React Native libraries",
5
5
  "keywords": [
6
6
  "react-native",
@@ -40,28 +40,28 @@
40
40
  "prepare": "babel --extensions .ts,.tsx src --out-dir lib --ignore '**/__tests__/**' --source-maps --delete-dir-on-start"
41
41
  },
42
42
  "dependencies": {
43
- "cross-spawn": "^7.0.3",
44
- "dedent": "^0.7.0",
45
- "ejs": "^3.1.8",
46
- "fs-extra": "^10.1.0",
47
- "get-latest-version": "^5.1.0",
48
- "github-username": "^6.0.0",
49
- "kleur": "^4.1.4",
50
- "ora": "^5.4.1",
51
- "pigment": "^0.3.11",
52
- "validate-npm-package-name": "^4.0.0"
43
+ "cross-spawn": "^7.0.6",
44
+ "dedent": "^1.7.2",
45
+ "ejs": "^5.0.1",
46
+ "fs-extra": "^11.3.4",
47
+ "get-latest-version": "^6.0.1",
48
+ "github-username": "^9.0.0",
49
+ "kleur": "^4.1.5",
50
+ "ora": "^9.3.0",
51
+ "pigment": "^0.4.1",
52
+ "validate-npm-package-name": "^7.0.2"
53
53
  },
54
54
  "devDependencies": {
55
- "@babel/cli": "^7.24.8",
56
- "@babel/core": "^7.25.2",
57
- "@babel/preset-env": "^7.25.2",
58
- "@babel/preset-typescript": "^7.24.7",
59
- "@commitlint/config-conventional": "^17.0.2",
60
- "@types/cross-spawn": "^6.0.2",
61
- "@types/dedent": "^0.7.0",
62
- "@types/ejs": "^3.1.1",
63
- "@types/fs-extra": "^9.0.13",
64
- "@types/validate-npm-package-name": "^3.0.3"
55
+ "@babel/cli": "^7.28.6",
56
+ "@babel/core": "^7.29.0",
57
+ "@babel/preset-env": "^7.29.2",
58
+ "@babel/preset-typescript": "^7.28.5",
59
+ "@commitlint/config-conventional": "^20.5.0",
60
+ "@types/cross-spawn": "^6.0.6",
61
+ "@types/dedent": "^0.7.2",
62
+ "@types/ejs": "^3.1.5",
63
+ "@types/fs-extra": "^11.0.4",
64
+ "@types/validate-npm-package-name": "^4.0.2"
65
65
  },
66
- "gitHead": "f3868e68e5e1457d762960c697249582a150c52a"
66
+ "gitHead": "9642b14695b4513ea27a197a60d3fc90c583de3d"
67
67
  }
@@ -61,7 +61,7 @@ jobs:
61
61
  - name: Build package
62
62
  run: yarn prepare
63
63
 
64
- <% if (project.native) { -%>
64
+ <% if (example != null) { -%>
65
65
  build-android:
66
66
  runs-on: ubuntu-latest
67
67
 
@@ -109,7 +109,7 @@ jobs:
109
109
  /bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
110
110
 
111
111
  <% if (example === 'expo') { -%>
112
- - name: Prebuild expo app for iOS
112
+ - name: Prebuild expo app for Android
113
113
  if: env.turbo_cache_hit != 1
114
114
  run: |
115
115
  yarn example expo prebuild --platform android
@@ -193,7 +193,9 @@ jobs:
193
193
  - name: Build example for iOS
194
194
  run: |
195
195
  yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"
196
- <% } else { -%>
196
+ <% } -%>
197
+
198
+ <% if (example === 'expo' || tools.includes('vite')) { -%>
197
199
  build-web:
198
200
  runs-on: ubuntu-latest
199
201
 
@@ -206,5 +208,5 @@ jobs:
206
208
 
207
209
  - name: Build example for Web
208
210
  run: |
209
- yarn example expo export --platform web
211
+ yarn example build:web
210
212
  <% } -%>
@@ -70,18 +70,18 @@
70
70
  },
71
71
  "devDependencies": {
72
72
  "@react-native/babel-preset": "0.83.0",
73
- "@types/react": "^19.1.12",
74
- "del-cli": "^6.0.0",
73
+ "@types/react": "^19.2.0",
74
+ "del-cli": "^7.0.0",
75
75
  <% if (project.moduleConfig === 'nitro-modules' || project.viewConfig === 'nitro-view') { -%>
76
76
  "nitrogen": "^<%- versions.nitro %>",
77
77
  <% } -%>
78
- "react": "19.1.0",
78
+ "react": "19.2.0",
79
79
  "react-native": "0.83.0",
80
80
  "react-native-builder-bob": "^<%- versions.bob %>",
81
81
  <% if (project.moduleConfig === 'nitro-modules' || project.viewConfig === 'nitro-view') { -%>
82
82
  "react-native-nitro-modules": "^<%- versions.nitro %>",
83
83
  <% } -%>
84
- "typescript": "^5.9.2"
84
+ "typescript": "^6.0.2"
85
85
  },
86
86
  "peerDependencies": {
87
87
  "react": "*",
@@ -76,7 +76,7 @@ Running "<%- project.name -%>Example" with {"fabric":true,"initialProps":{"concu
76
76
 
77
77
  Note the `"fabric":true` and `"concurrentRoot":true` properties.
78
78
 
79
- <% if (!project.native) { -%>
79
+ <% if (example === 'expo' || tools.includes('vite')) { -%>
80
80
  To run the example app on Web:
81
81
 
82
82
  ```sh
@@ -148,15 +148,19 @@ The `package.json` file contains various scripts for common tasks:
148
148
 
149
149
  - `yarn`: setup project by installing dependencies.
150
150
  - `yarn typecheck`: type-check files with TypeScript.
151
- <% if (tools.includes('eslint')) { -%>
151
+ <% if (tools.includes('eslint')) { -%>
152
152
  - `yarn lint`: lint files with [ESLint](https://eslint.org/).
153
- <% } -%>
154
- <% if (tools.includes('jest')) { -%>
153
+ <% } -%>
154
+ <% if (tools.includes('jest')) { -%>
155
155
  - `yarn test`: run unit tests with [Jest](https://jestjs.io/).
156
- <% } -%>
156
+ <% } -%>
157
157
  - `yarn example start`: start the Metro server for the example app.
158
158
  - `yarn example android`: run the example app on Android.
159
159
  - `yarn example ios`: run the example app on iOS.
160
+ <% if (example === 'expo' || tools.includes('vite')) { -%>
161
+ - `yarn example web`: run the example app on Web.
162
+ - `yarn example build:web`: build the example app for Web.
163
+ <% } -%>
160
164
 
161
165
  ### Sending a pull request
162
166
 
@@ -32,16 +32,6 @@ import { <%- project.name -%>View } from "<%- project.slug -%>";
32
32
  <<%- project.name -%>View color="tomato" />
33
33
  ```
34
34
 
35
- <% } else if (project.moduleConfig === 'nitro-modules' || project.viewConfig === 'nitro-view' || project.moduleConfig === 'turbo-modules') { -%>
36
-
37
- ```js
38
- import { multiply } from '<%- project.slug -%>';
39
-
40
- // ...
41
-
42
- const result = multiply(3, 7);
43
- ```
44
-
45
35
  <% } else { -%>
46
36
 
47
37
  ```js
@@ -49,7 +39,7 @@ import { multiply } from '<%- project.slug -%>';
49
39
 
50
40
  // ...
51
41
 
52
- const result = await multiply(3, 7);
42
+ const result = multiply(3, 7);
53
43
  ```
54
44
 
55
45
  <% } -%>
@@ -1,3 +1 @@
1
- export function multiply(a: number, b: number): number {
2
- return a * b;
3
- }
1
+ export { multiply } from './multiply';
@@ -0,0 +1,3 @@
1
+ export function multiply(a: number, b: number): number {
2
+ return a * b;
3
+ }
@@ -0,0 +1 @@
1
+ export { <%- project.name -%>View } from './<%- project.name -%>View';
@@ -0,0 +1,9 @@
1
+ import { View, type ColorValue, type ViewProps } from 'react-native';
2
+
3
+ type Props = ViewProps & {
4
+ color?: ColorValue;
5
+ };
6
+
7
+ export function <%- project.name -%>View({ color, style, ...rest }: Props) {
8
+ return <View {...rest} style={[style, { backgroundColor: color }]} />;
9
+ }
@@ -1,5 +1 @@
1
- import <%- project.name -%> from './Native<%- project.name -%>';
2
-
3
- export function multiply(a: number, b: number): number {
4
- return <%- project.name -%>.multiply(a, b);
5
- }
1
+ export { multiply } from './multiply';
@@ -0,0 +1,5 @@
1
+ import <%- project.name -%> from './Native<%- project.name -%>';
2
+
3
+ export function multiply(a: number, b: number): number {
4
+ return <%- project.name -%>.multiply(a, b);
5
+ }
@@ -0,0 +1,5 @@
1
+ export function multiply(_a: number, _b: number): number {
2
+ throw new Error(
3
+ "'<%- project.slug -%>' is only supported on native platforms."
4
+ );
5
+ }
@@ -1,2 +1 @@
1
- export { default as <%- project.name -%>View } from './<%- project.name -%>ViewNativeComponent';
2
- export * from './<%- project.name -%>ViewNativeComponent';
1
+ export { <%- project.name -%>View } from './<%- project.name -%>View';
@@ -0,0 +1,2 @@
1
+ export { default as <%- project.name -%>View } from './<%- project.name -%>ViewNativeComponent';
2
+ export * from './<%- project.name -%>ViewNativeComponent';
@@ -0,0 +1,11 @@
1
+ import type { ColorValue, ViewProps } from 'react-native';
2
+
3
+ type Props = ViewProps & {
4
+ color?: ColorValue;
5
+ };
6
+
7
+ export function <%- project.name -%>View(_props: Props): never {
8
+ throw new Error(
9
+ "'<%- project.slug -%>' is only supported on native platforms."
10
+ );
11
+ }
@@ -9,8 +9,14 @@
9
9
  },
10
10
  "autolinking": {
11
11
  "<%- project.name -%>": {
12
- "swift": "<% if (project.viewConfig === 'nitro-view') { -%>Hybrid<% } -%><%- project.name -%>",
13
- "kotlin": "<% if (project.viewConfig === 'nitro-view') { -%>Hybrid<% } -%><%- project.name -%>"
12
+ "ios": {
13
+ "language": "swift",
14
+ "implementationClassName": "<% if (project.viewConfig === 'nitro-view') { -%>Hybrid<% } -%><%- project.name -%>"
15
+ },
16
+ "android": {
17
+ "language": "kotlin",
18
+ "implementationClassName": "<% if (project.viewConfig === 'nitro-view') { -%>Hybrid<% } -%><%- project.name -%>"
19
+ }
14
20
  }
15
21
  },
16
22
  "ignorePaths": ["node_modules"]
@@ -1,9 +1 @@
1
- import { NitroModules } from 'react-native-nitro-modules';
2
- import type { <%- project.name -%> } from './<%- project.name -%>.nitro';
3
-
4
- const <%- project.name -%>HybridObject =
5
- NitroModules.createHybridObject<<%- project.name -%>>('<%- project.name -%>');
6
-
7
- export function multiply(a: number, b: number): number {
8
- return <%- project.name -%>HybridObject.multiply(a, b);
9
- }
1
+ export { multiply } from './multiply';
@@ -0,0 +1,9 @@
1
+ import { NitroModules } from 'react-native-nitro-modules';
2
+ import type { <%- project.name -%> } from './<%- project.name -%>.nitro';
3
+
4
+ const <%- project.name -%>HybridObject =
5
+ NitroModules.createHybridObject<<%- project.name -%>>('<%- project.name -%>');
6
+
7
+ export function multiply(a: number, b: number): number {
8
+ return <%- project.name -%>HybridObject.multiply(a, b);
9
+ }
@@ -0,0 +1,5 @@
1
+ export function multiply(_a: number, _b: number): number {
2
+ throw new Error(
3
+ "'<%- project.slug -%>' is only supported on native platforms."
4
+ );
5
+ }
@@ -1,6 +1,8 @@
1
1
  import type { HybridObject } from 'react-native-nitro-modules';
2
2
 
3
- export interface <%- project.name %>
4
- extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
3
+ export interface <%- project.name %> extends HybridObject<{
4
+ ios: 'swift';
5
+ android: 'kotlin';
6
+ }> {
5
7
  multiply(a: number, b: number): number;
6
8
  }
@@ -1,11 +1 @@
1
- import { getHostComponent } from 'react-native-nitro-modules';
2
- const <%- project.name %>Config = require('../nitrogen/generated/shared/json/<%- project.name %>Config.json');
3
- import type {
4
- <%- project.name %>Methods,
5
- <%- project.name %>Props,
6
- } from './<%- project.name %>.nitro';
7
-
8
- export const <%- project.name %>View = getHostComponent<
9
- <%- project.name %>Props,
10
- <%- project.name %>Methods
11
- >('<%- project.name %>', () => <%- project.name %>Config);
1
+ export { <%- project.name -%>View } from './<%- project.name -%>View';
@@ -0,0 +1,11 @@
1
+ import { getHostComponent } from 'react-native-nitro-modules';
2
+ const <%- project.name %>Config = require('../nitrogen/generated/shared/json/<%- project.name %>Config.json');
3
+ import type {
4
+ <%- project.name %>Methods,
5
+ <%- project.name %>Props,
6
+ } from './<%- project.name %>.nitro';
7
+
8
+ export const <%- project.name %>View = getHostComponent<
9
+ <%- project.name %>Props,
10
+ <%- project.name %>Methods
11
+ >('<%- project.name %>', () => <%- project.name %>Config);
@@ -0,0 +1,11 @@
1
+ import type { ColorValue, ViewProps } from 'react-native';
2
+
3
+ type Props = ViewProps & {
4
+ color?: ColorValue;
5
+ };
6
+
7
+ export function <%- project.name -%>View(_props: Props): never {
8
+ throw new Error(
9
+ "'<%- project.slug -%>' is only supported on native platforms."
10
+ );
11
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "scripts": {
3
+ "lint": "eslint \"**/*.{js,ts,tsx}\""
4
+ },
5
+ "prettier": {
6
+ "quoteProps": "consistent",
7
+ "singleQuote": true,
8
+ "tabWidth": 2,
9
+ "trailingComma": "es5",
10
+ "useTabs": false
11
+ },
12
+ "devDependencies": {
13
+ "@eslint/compat": "^2.0.3",
14
+ "@eslint/eslintrc": "^3.3.5",
15
+ "@eslint/js": "^10.0.1",
16
+ "@react-native/eslint-config": "0.83.0",
17
+ "eslint": "^9.39.4",
18
+ "eslint-config-prettier": "^10.1.8",
19
+ "eslint-plugin-ft-flow": "^3.0.11",
20
+ "eslint-plugin-prettier": "^5.5.5",
21
+ "prettier": "^3.8.1"
22
+ }
23
+ }
@@ -1 +1,3 @@
1
+ import { it } from '@jest/globals';
2
+
1
3
  it.todo('write a test');