create-react-native-library 0.45.5 → 0.47.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/lib/template.js CHANGED
@@ -55,7 +55,7 @@ function generateTemplateConfiguration({
55
55
  languages,
56
56
  type
57
57
  } = answers;
58
- const arch = type === 'legacy-module' || type === 'legacy-view' ? 'legacy' : 'new';
58
+ const arch = type === 'legacy-module' || type === 'legacy-view' || type === 'library' ? 'legacy' : 'new';
59
59
  const project = slug.replace(/^(react-native-|@[^/]+\/)/, '');
60
60
  let namespace;
61
61
  if (slug.startsWith('@') && slug.includes('/')) {
@@ -1 +1 @@
1
- {"version":3,"file":"template.js","names":["_path","_interopRequireDefault","require","_fsExtra","_ejs","e","__esModule","default","BINARIES","COMMON_FILES","path","resolve","__dirname","COMMON_LOCAL_FILES","EXAMPLE_COMMON_FILES","EXAMPLE_MODULE_LEGACY_FILES","EXAMPLE_MODULE_NEW_FILES","EXAMPLE_VIEW_FILES","JS_FILES","EXPO_FILES","CPP_FILES","NATIVE_COMMON_FILES","NATIVE_COMMON_EXAMPLE_FILES","NATIVE_FILES","module_legacy","module_new","view_legacy","view_new","OBJC_FILES","module_common","KOTLIN_FILES","SWIFT_FILES","generateTemplateConfiguration","bobVersion","basename","answers","slug","languages","type","arch","project","replace","namespace","startsWith","includes","split","toLowerCase","pack","bob","version","description","name","test","charAt","toUpperCase","_","$1","slice","package","package_dir","package_cpp","identifier","native","cpp","swift","view","endsWith","module","author","authorName","email","authorEmail","url","authorUrl","repo","repoUrl","example","year","Date","getFullYear","applyTemplates","config","folder","local","applyTemplate","templateType","fs","remove","join","source","destination","mkdirp","files","readdir","f","target","ejs","render","openDelimiter","closeDelimiter","file","stats","stat","isDirectory","some","r","content","readFile","writeFile","copyFile"],"sources":["../src/template.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs-extra';\nimport ejs from 'ejs';\nimport type { Answers, ExampleApp, SupportedArchitecture } from './input';\n\n// Please think at least 5 times before introducing a new config key\n// You can just reuse the existing ones most of the time\nexport type TemplateConfiguration = {\n bob: {\n version: string;\n };\n project: {\n slug: string;\n description: string;\n name: string;\n package: string;\n package_dir: string;\n package_cpp: string;\n identifier: string;\n native: boolean;\n arch: SupportedArchitecture;\n cpp: boolean;\n swift: boolean;\n view: boolean;\n module: boolean;\n };\n author: {\n name: string;\n email: string;\n url: string;\n };\n repo: string;\n example: ExampleApp;\n year: number;\n};\n\nconst BINARIES = [\n /(gradlew|\\.(jar|keystore|png|jpg|gif))$/,\n /\\$\\.yarn(?![a-z])/,\n];\n\nconst COMMON_FILES = path.resolve(__dirname, '../templates/common');\nconst COMMON_LOCAL_FILES = path.resolve(__dirname, '../templates/common-local');\nconst EXAMPLE_COMMON_FILES = path.resolve(\n __dirname,\n '../templates/example-common'\n);\nconst EXAMPLE_MODULE_LEGACY_FILES = path.resolve(\n __dirname,\n '../templates/example-module-legacy'\n);\nconst EXAMPLE_MODULE_NEW_FILES = path.resolve(\n __dirname,\n '../templates/example-module-new'\n);\nconst EXAMPLE_VIEW_FILES = path.resolve(__dirname, '../templates/example-view');\n\nconst JS_FILES = path.resolve(__dirname, '../templates/js-library');\nconst EXPO_FILES = path.resolve(__dirname, '../templates/expo-library');\nconst CPP_FILES = path.resolve(__dirname, '../templates/cpp-library');\nconst NATIVE_COMMON_FILES = path.resolve(\n __dirname,\n '../templates/native-common'\n);\nconst NATIVE_COMMON_EXAMPLE_FILES = path.resolve(\n __dirname,\n '../templates/native-common-example'\n);\n\nconst NATIVE_FILES = {\n module_legacy: path.resolve(__dirname, '../templates/native-library-legacy'),\n module_new: path.resolve(__dirname, '../templates/native-library-new'),\n view_legacy: path.resolve(__dirname, '../templates/native-view-legacy'),\n view_new: path.resolve(__dirname, '../templates/native-view-new'),\n} as const;\n\nconst OBJC_FILES = {\n module_common: path.resolve(__dirname, '../templates/objc-library'),\n view_legacy: path.resolve(__dirname, '../templates/objc-view-legacy'),\n view_new: path.resolve(__dirname, '../templates/objc-view-new'),\n} as const;\n\nconst KOTLIN_FILES = {\n module_legacy: path.resolve(__dirname, '../templates/kotlin-library-legacy'),\n module_new: path.resolve(__dirname, '../templates/kotlin-library-new'),\n view_legacy: path.resolve(__dirname, '../templates/kotlin-view-legacy'),\n view_new: path.resolve(__dirname, '../templates/kotlin-view-new'),\n} as const;\n\nconst SWIFT_FILES = {\n module_legacy: path.resolve(__dirname, '../templates/swift-library-legacy'),\n view_legacy: path.resolve(__dirname, '../templates/swift-view-legacy'),\n} as const;\n\nexport function generateTemplateConfiguration({\n bobVersion,\n basename,\n answers,\n}: {\n bobVersion: string;\n basename: string;\n answers: Answers;\n}): TemplateConfiguration {\n const { slug, languages, type } = answers;\n\n const arch =\n type === 'legacy-module' || type === 'legacy-view' ? 'legacy' : 'new';\n\n const project = slug.replace(/^(react-native-|@[^/]+\\/)/, '');\n let namespace: string | undefined;\n\n if (slug.startsWith('@') && slug.includes('/')) {\n namespace = slug\n .split('/')[0]\n ?.replace(/[^a-z0-9]/g, '')\n .toLowerCase();\n }\n\n // Create a package identifier with specified namespace when possible\n const pack = `${namespace ? `${namespace}.` : ''}${project\n .replace(/[^a-z0-9]/g, '')\n .toLowerCase()}`;\n\n return {\n bob: {\n version: bobVersion,\n },\n project: {\n slug,\n description: answers.description,\n name:\n /^[A-Z]/.test(basename) && /^[a-z0-9]+$/i.test(basename)\n ? // If the project name is already in PascalCase, use it as-is\n basename\n : // Otherwise, convert it to PascalCase and remove any non-alphanumeric characters\n `${project.charAt(0).toUpperCase()}${project\n .replace(/[^a-z0-9](\\w)/g, (_, $1) => $1.toUpperCase())\n .slice(1)}`,\n package: pack,\n package_dir: pack.replace(/\\./g, '/'),\n package_cpp: pack.replace(/\\./g, '_'),\n identifier: slug.replace(/[^a-z0-9]+/g, '-').replace(/^-/, ''),\n native: languages !== 'js',\n arch,\n cpp: languages === 'cpp',\n swift: languages === 'kotlin-swift',\n view: answers.type.endsWith('-view'),\n module: answers.type.endsWith('-module'),\n },\n author: {\n name: answers.authorName,\n email: answers.authorEmail,\n url: answers.authorUrl,\n },\n repo: answers.repoUrl,\n example: answers.example,\n year: new Date().getFullYear(),\n };\n}\n\nexport async function applyTemplates(\n answers: Answers,\n config: TemplateConfiguration,\n folder: string\n) {\n const { local } = answers;\n if (local) {\n await applyTemplate(config, COMMON_LOCAL_FILES, folder);\n } else {\n await applyTemplate(config, COMMON_FILES, folder);\n\n if (config.example !== 'none') {\n await applyTemplate(config, EXAMPLE_COMMON_FILES, folder);\n\n if (config.project.view) {\n await applyTemplate(config, EXAMPLE_VIEW_FILES, folder);\n } else {\n if (config.project.arch === 'legacy') {\n await applyTemplate(config, EXAMPLE_MODULE_LEGACY_FILES, folder);\n } else {\n await applyTemplate(config, EXAMPLE_MODULE_NEW_FILES, folder);\n }\n }\n }\n }\n\n if (answers.languages === 'js') {\n await applyTemplate(config, JS_FILES, folder);\n await applyTemplate(config, EXPO_FILES, folder);\n } else {\n await applyTemplate(config, NATIVE_COMMON_FILES, folder);\n\n if (config.example !== 'none') {\n await applyTemplate(config, NATIVE_COMMON_EXAMPLE_FILES, folder);\n }\n\n if (config.project.module) {\n await applyTemplate(\n config,\n NATIVE_FILES[`module_${config.project.arch}`],\n folder\n );\n } else {\n await applyTemplate(\n config,\n NATIVE_FILES[`view_${config.project.arch}`],\n folder\n );\n }\n\n if (config.project.swift) {\n await applyTemplate(config, SWIFT_FILES[`module_legacy`], folder);\n } else {\n if (config.project.module) {\n await applyTemplate(config, OBJC_FILES[`module_common`], folder);\n } else {\n await applyTemplate(\n config,\n OBJC_FILES[`view_${config.project.arch}`],\n folder\n );\n }\n }\n\n const templateType = `${config.project.module ? 'module' : 'view'}_${\n config.project.arch\n }` as const;\n\n await applyTemplate(config, KOTLIN_FILES[templateType], folder);\n\n if (config.project.cpp) {\n await applyTemplate(config, CPP_FILES, folder);\n await fs.remove(path.join(folder, 'ios', `${config.project.name}.m`));\n }\n }\n}\n\n/**\n * This copies the template files and renders them via ejs\n */\nasync function applyTemplate(\n config: TemplateConfiguration,\n source: string,\n destination: string\n) {\n await fs.mkdirp(destination);\n\n const files = await fs.readdir(source);\n\n for (const f of files) {\n const target = path.join(\n destination,\n ejs.render(f.replace(/^\\$/, ''), config, {\n openDelimiter: '{',\n closeDelimiter: '}',\n })\n );\n\n const file = path.join(source, f);\n const stats = await fs.stat(file);\n\n if (stats.isDirectory()) {\n await applyTemplate(config, file, target);\n } else if (!BINARIES.some((r) => r.test(file))) {\n const content = await fs.readFile(file, 'utf8');\n\n await fs.writeFile(target, ejs.render(content, config));\n } else {\n await fs.copyFile(file, target);\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,IAAA,GAAAH,sBAAA,CAAAC,OAAA;AAAsB,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGtB;AACA;;AA8BA,MAAMG,QAAQ,GAAG,CACf,yCAAyC,EACzC,mBAAmB,CACpB;AAED,MAAMC,YAAY,GAAGC,aAAI,CAACC,OAAO,CAACC,SAAS,EAAE,qBAAqB,CAAC;AACnE,MAAMC,kBAAkB,GAAGH,aAAI,CAACC,OAAO,CAACC,SAAS,EAAE,2BAA2B,CAAC;AAC/E,MAAME,oBAAoB,GAAGJ,aAAI,CAACC,OAAO,CACvCC,SAAS,EACT,6BACF,CAAC;AACD,MAAMG,2BAA2B,GAAGL,aAAI,CAACC,OAAO,CAC9CC,SAAS,EACT,oCACF,CAAC;AACD,MAAMI,wBAAwB,GAAGN,aAAI,CAACC,OAAO,CAC3CC,SAAS,EACT,iCACF,CAAC;AACD,MAAMK,kBAAkB,GAAGP,aAAI,CAACC,OAAO,CAACC,SAAS,EAAE,2BAA2B,CAAC;AAE/E,MAAMM,QAAQ,GAAGR,aAAI,CAACC,OAAO,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gBAAE,CAACO,OAAO,CAACJ,MAAM,CAAC;EAEtC,KAAK,MAAMK,CAAC,IAAIF,KAAK,EAAE;IACrB,MAAMG,MAAM,GAAGrF,aAAI,CAAC8E,IAAI,CACtBE,WAAW,EACXM,YAAG,CAACC,MAAM,CAACH,CAAC,CAACrD,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAEwC,MAAM,EAAE;MACvCiB,aAAa,EAAE,GAAG;MAClBC,cAAc,EAAE;IAClB,CAAC,CACH,CAAC;IAED,MAAMC,IAAI,GAAG1F,aAAI,CAAC8E,IAAI,CAACC,MAAM,EAAEK,CAAC,CAAC;IACjC,MAAMO,KAAK,GAAG,MAAMf,gBAAE,CAACgB,IAAI,CAACF,IAAI,CAAC;IAEjC,IAAIC,KAAK,CAACE,WAAW,CAAC,CAAC,EAAE;MACvB,MAAMnB,aAAa,CAACH,MAAM,EAAEmB,IAAI,EAAEL,MAAM,CAAC;IAC3C,CAAC,MAAM,IAAI,CAACvF,QAAQ,CAACgG,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACrD,IAAI,CAACgD,IAAI,CAAC,CAAC,EAAE;MAC9C,MAAMM,OAAO,GAAG,MAAMpB,gBAAE,CAACqB,QAAQ,CAACP,IAAI,EAAE,MAAM,CAAC;MAE/C,MAAMd,gBAAE,CAACsB,SAAS,CAACb,MAAM,EAAEC,YAAG,CAACC,MAAM,CAACS,OAAO,EAAEzB,MAAM,CAAC,CAAC;IACzD,CAAC,MAAM;MACL,MAAMK,gBAAE,CAACuB,QAAQ,CAACT,IAAI,EAAEL,MAAM,CAAC;IACjC;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"template.js","names":["_path","_interopRequireDefault","require","_fsExtra","_ejs","e","__esModule","default","BINARIES","COMMON_FILES","path","resolve","__dirname","COMMON_LOCAL_FILES","EXAMPLE_COMMON_FILES","EXAMPLE_MODULE_LEGACY_FILES","EXAMPLE_MODULE_NEW_FILES","EXAMPLE_VIEW_FILES","JS_FILES","EXPO_FILES","CPP_FILES","NATIVE_COMMON_FILES","NATIVE_COMMON_EXAMPLE_FILES","NATIVE_FILES","module_legacy","module_new","view_legacy","view_new","OBJC_FILES","module_common","KOTLIN_FILES","SWIFT_FILES","generateTemplateConfiguration","bobVersion","basename","answers","slug","languages","type","arch","project","replace","namespace","startsWith","includes","split","toLowerCase","pack","bob","version","description","name","test","charAt","toUpperCase","_","$1","slice","package","package_dir","package_cpp","identifier","native","cpp","swift","view","endsWith","module","author","authorName","email","authorEmail","url","authorUrl","repo","repoUrl","example","year","Date","getFullYear","applyTemplates","config","folder","local","applyTemplate","templateType","fs","remove","join","source","destination","mkdirp","files","readdir","f","target","ejs","render","openDelimiter","closeDelimiter","file","stats","stat","isDirectory","some","r","content","readFile","writeFile","copyFile"],"sources":["../src/template.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs-extra';\nimport ejs from 'ejs';\nimport type { Answers, ExampleApp, SupportedArchitecture } from './input';\n\n// Please think at least 5 times before introducing a new config key\n// You can just reuse the existing ones most of the time\nexport type TemplateConfiguration = {\n bob: {\n version: string;\n };\n project: {\n slug: string;\n description: string;\n name: string;\n package: string;\n package_dir: string;\n package_cpp: string;\n identifier: string;\n native: boolean;\n arch: SupportedArchitecture;\n cpp: boolean;\n swift: boolean;\n view: boolean;\n module: boolean;\n };\n author: {\n name: string;\n email: string;\n url: string;\n };\n repo: string;\n example: ExampleApp;\n year: number;\n};\n\nconst BINARIES = [\n /(gradlew|\\.(jar|keystore|png|jpg|gif))$/,\n /\\$\\.yarn(?![a-z])/,\n];\n\nconst COMMON_FILES = path.resolve(__dirname, '../templates/common');\nconst COMMON_LOCAL_FILES = path.resolve(__dirname, '../templates/common-local');\nconst EXAMPLE_COMMON_FILES = path.resolve(\n __dirname,\n '../templates/example-common'\n);\nconst EXAMPLE_MODULE_LEGACY_FILES = path.resolve(\n __dirname,\n '../templates/example-module-legacy'\n);\nconst EXAMPLE_MODULE_NEW_FILES = path.resolve(\n __dirname,\n '../templates/example-module-new'\n);\nconst EXAMPLE_VIEW_FILES = path.resolve(__dirname, '../templates/example-view');\n\nconst JS_FILES = path.resolve(__dirname, '../templates/js-library');\nconst EXPO_FILES = path.resolve(__dirname, '../templates/expo-library');\nconst CPP_FILES = path.resolve(__dirname, '../templates/cpp-library');\nconst NATIVE_COMMON_FILES = path.resolve(\n __dirname,\n '../templates/native-common'\n);\nconst NATIVE_COMMON_EXAMPLE_FILES = path.resolve(\n __dirname,\n '../templates/native-common-example'\n);\n\nconst NATIVE_FILES = {\n module_legacy: path.resolve(__dirname, '../templates/native-library-legacy'),\n module_new: path.resolve(__dirname, '../templates/native-library-new'),\n view_legacy: path.resolve(__dirname, '../templates/native-view-legacy'),\n view_new: path.resolve(__dirname, '../templates/native-view-new'),\n} as const;\n\nconst OBJC_FILES = {\n module_common: path.resolve(__dirname, '../templates/objc-library'),\n view_legacy: path.resolve(__dirname, '../templates/objc-view-legacy'),\n view_new: path.resolve(__dirname, '../templates/objc-view-new'),\n} as const;\n\nconst KOTLIN_FILES = {\n module_legacy: path.resolve(__dirname, '../templates/kotlin-library-legacy'),\n module_new: path.resolve(__dirname, '../templates/kotlin-library-new'),\n view_legacy: path.resolve(__dirname, '../templates/kotlin-view-legacy'),\n view_new: path.resolve(__dirname, '../templates/kotlin-view-new'),\n} as const;\n\nconst SWIFT_FILES = {\n module_legacy: path.resolve(__dirname, '../templates/swift-library-legacy'),\n view_legacy: path.resolve(__dirname, '../templates/swift-view-legacy'),\n} as const;\n\nexport function generateTemplateConfiguration({\n bobVersion,\n basename,\n answers,\n}: {\n bobVersion: string;\n basename: string;\n answers: Answers;\n}): TemplateConfiguration {\n const { slug, languages, type } = answers;\n\n const arch =\n type === 'legacy-module' || type === 'legacy-view' || type === 'library'\n ? 'legacy'\n : 'new';\n\n const project = slug.replace(/^(react-native-|@[^/]+\\/)/, '');\n let namespace: string | undefined;\n\n if (slug.startsWith('@') && slug.includes('/')) {\n namespace = slug\n .split('/')[0]\n ?.replace(/[^a-z0-9]/g, '')\n .toLowerCase();\n }\n\n // Create a package identifier with specified namespace when possible\n const pack = `${namespace ? `${namespace}.` : ''}${project\n .replace(/[^a-z0-9]/g, '')\n .toLowerCase()}`;\n\n return {\n bob: {\n version: bobVersion,\n },\n project: {\n slug,\n description: answers.description,\n name:\n /^[A-Z]/.test(basename) && /^[a-z0-9]+$/i.test(basename)\n ? // If the project name is already in PascalCase, use it as-is\n basename\n : // Otherwise, convert it to PascalCase and remove any non-alphanumeric characters\n `${project.charAt(0).toUpperCase()}${project\n .replace(/[^a-z0-9](\\w)/g, (_, $1) => $1.toUpperCase())\n .slice(1)}`,\n package: pack,\n package_dir: pack.replace(/\\./g, '/'),\n package_cpp: pack.replace(/\\./g, '_'),\n identifier: slug.replace(/[^a-z0-9]+/g, '-').replace(/^-/, ''),\n native: languages !== 'js',\n arch,\n cpp: languages === 'cpp',\n swift: languages === 'kotlin-swift',\n view: answers.type.endsWith('-view'),\n module: answers.type.endsWith('-module'),\n },\n author: {\n name: answers.authorName,\n email: answers.authorEmail,\n url: answers.authorUrl,\n },\n repo: answers.repoUrl,\n example: answers.example,\n year: new Date().getFullYear(),\n };\n}\n\nexport async function applyTemplates(\n answers: Answers,\n config: TemplateConfiguration,\n folder: string\n) {\n const { local } = answers;\n if (local) {\n await applyTemplate(config, COMMON_LOCAL_FILES, folder);\n } else {\n await applyTemplate(config, COMMON_FILES, folder);\n\n if (config.example !== 'none') {\n await applyTemplate(config, EXAMPLE_COMMON_FILES, folder);\n\n if (config.project.view) {\n await applyTemplate(config, EXAMPLE_VIEW_FILES, folder);\n } else {\n if (config.project.arch === 'legacy') {\n await applyTemplate(config, EXAMPLE_MODULE_LEGACY_FILES, folder);\n } else {\n await applyTemplate(config, EXAMPLE_MODULE_NEW_FILES, folder);\n }\n }\n }\n }\n\n if (answers.languages === 'js') {\n await applyTemplate(config, JS_FILES, folder);\n await applyTemplate(config, EXPO_FILES, folder);\n } else {\n await applyTemplate(config, NATIVE_COMMON_FILES, folder);\n\n if (config.example !== 'none') {\n await applyTemplate(config, NATIVE_COMMON_EXAMPLE_FILES, folder);\n }\n\n if (config.project.module) {\n await applyTemplate(\n config,\n NATIVE_FILES[`module_${config.project.arch}`],\n folder\n );\n } else {\n await applyTemplate(\n config,\n NATIVE_FILES[`view_${config.project.arch}`],\n folder\n );\n }\n\n if (config.project.swift) {\n await applyTemplate(config, SWIFT_FILES[`module_legacy`], folder);\n } else {\n if (config.project.module) {\n await applyTemplate(config, OBJC_FILES[`module_common`], folder);\n } else {\n await applyTemplate(\n config,\n OBJC_FILES[`view_${config.project.arch}`],\n folder\n );\n }\n }\n\n const templateType = `${config.project.module ? 'module' : 'view'}_${\n config.project.arch\n }` as const;\n\n await applyTemplate(config, KOTLIN_FILES[templateType], folder);\n\n if (config.project.cpp) {\n await applyTemplate(config, CPP_FILES, folder);\n await fs.remove(path.join(folder, 'ios', `${config.project.name}.m`));\n }\n }\n}\n\n/**\n * This copies the template files and renders them via ejs\n */\nasync function applyTemplate(\n config: TemplateConfiguration,\n source: string,\n destination: string\n) {\n await fs.mkdirp(destination);\n\n const files = await fs.readdir(source);\n\n for (const f of files) {\n const target = path.join(\n destination,\n ejs.render(f.replace(/^\\$/, ''), config, {\n openDelimiter: '{',\n closeDelimiter: '}',\n })\n );\n\n const file = path.join(source, f);\n const stats = await fs.stat(file);\n\n if (stats.isDirectory()) {\n await applyTemplate(config, file, target);\n } else if (!BINARIES.some((r) => r.test(file))) {\n const content = await fs.readFile(file, 'utf8');\n\n await fs.writeFile(target, ejs.render(content, config));\n } else {\n await fs.copyFile(file, target);\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,IAAA,GAAAH,sBAAA,CAAAC,OAAA;AAAsB,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA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AAM,IAAI,CAACvF,QAAQ,CAACgG,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACrD,IAAI,CAACgD,IAAI,CAAC,CAAC,EAAE;MAC9C,MAAMM,OAAO,GAAG,MAAMpB,gBAAE,CAACqB,QAAQ,CAACP,IAAI,EAAE,MAAM,CAAC;MAE/C,MAAMd,gBAAE,CAACsB,SAAS,CAACb,MAAM,EAAEC,YAAG,CAACC,MAAM,CAACS,OAAO,EAAEzB,MAAM,CAAC,CAAC;IACzD,CAAC,MAAM;MACL,MAAMK,gBAAE,CAACuB,QAAQ,CAACT,IAAI,EAAEL,MAAM,CAAC;IACjC;EACF;AACF","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-react-native-library",
3
- "version": "0.45.5",
3
+ "version": "0.47.0",
4
4
  "description": "CLI to scaffold React Native libraries",
5
5
  "keywords": [
6
6
  "react-native",
@@ -30,7 +30,7 @@
30
30
  "templates"
31
31
  ],
32
32
  "engines": {
33
- "node": ">= 18.0.0"
33
+ "node": ">= 20.0.0"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public",
@@ -65,5 +65,5 @@
65
65
  "@types/validate-npm-package-name": "^3.0.3",
66
66
  "@types/yargs": "^17.0.10"
67
67
  },
68
- "gitHead": "a0ca7d2626d730080fb7f5b6f9291244b0cd711d"
68
+ "gitHead": "f06514d852d578df98008b0ce87de69e0fde59bd"
69
69
  }
@@ -0,0 +1,68 @@
1
+ name: 🐛 Bug report
2
+ description: Report a reproducible bug or regression in this library.
3
+ labels: [bug]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ # Bug report
9
+
10
+ 👋 Hi!
11
+
12
+ **Please fill the following carefully before opening a new issue ❗**
13
+ *(Your issue may be closed if it doesn't provide the required pieces of information)*
14
+ - type: checkboxes
15
+ attributes:
16
+ label: Before submitting a new issue
17
+ description: Please perform simple checks first.
18
+ options:
19
+ - label: I tested using the latest version of the library, as the bug might be already fixed.
20
+ required: true
21
+ - label: I tested using a [supported version](https://github.com/reactwg/react-native-releases/blob/main/docs/support.md) of react native.
22
+ required: true
23
+ - label: I checked for possible duplicate issues, with possible answers.
24
+ required: true
25
+ - type: textarea
26
+ id: summary
27
+ attributes:
28
+ label: Bug summary
29
+ description: |
30
+ Provide a clear and concise description of what the bug is.
31
+ If needed, you can also provide other samples: error messages / stack traces, screenshots, gifs, etc.
32
+ validations:
33
+ required: true
34
+ - type: input
35
+ id: library-version
36
+ attributes:
37
+ label: Library version
38
+ description: What version of the library are you using?
39
+ placeholder: "x.x.x"
40
+ validations:
41
+ required: true
42
+ - type: textarea
43
+ id: react-native-info
44
+ attributes:
45
+ label: Environment info
46
+ description: Run `react-native info` in your terminal and paste the results here.
47
+ render: shell
48
+ validations:
49
+ required: true
50
+ - type: textarea
51
+ id: steps-to-reproduce
52
+ attributes:
53
+ label: Steps to reproduce
54
+ description: |
55
+ You must provide a clear list of steps and code to reproduce the problem.
56
+ value: |
57
+ 1. …
58
+ 2. …
59
+ validations:
60
+ required: true
61
+ - type: input
62
+ id: reproducible-example
63
+ attributes:
64
+ label: Reproducible example repository
65
+ description: Please provide a link to a repository on GitHub with a reproducible example.
66
+ render: js
67
+ validations:
68
+ required: true
@@ -0,0 +1,8 @@
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: Feature Request 💡
4
+ url: <%- repo -%>/discussions/new?category=ideas
5
+ about: If you have a feature request, please create a new discussion on GitHub.
6
+ - name: Discussions on GitHub 💬
7
+ url: <%- repo -%>/discussions
8
+ about: If this library works as promised but you need help, please ask questions there.
@@ -5,13 +5,13 @@ runs:
5
5
  using: composite
6
6
  steps:
7
7
  - name: Setup Node.js
8
- uses: actions/setup-node@v3
8
+ uses: actions/setup-node@v4
9
9
  with:
10
10
  node-version-file: .nvmrc
11
11
 
12
- - name: Cache dependencies
12
+ - name: Restore dependencies
13
13
  id: yarn-cache
14
- uses: actions/cache@v3
14
+ uses: actions/cache/restore@v4
15
15
  with:
16
16
  path: |
17
17
  **/node_modules
@@ -25,3 +25,12 @@ runs:
25
25
  if: steps.yarn-cache.outputs.cache-hit != 'true'
26
26
  run: yarn install --immutable
27
27
  shell: bash
28
+
29
+ - name: Cache dependencies
30
+ if: steps.yarn-cache.outputs.cache-hit != 'true'
31
+ uses: actions/cache/save@v4
32
+ with:
33
+ path: |
34
+ **/node_modules
35
+ .yarn/install-state.gz
36
+ key: ${{ steps.yarn-cache.outputs.cache-primary-key }}
@@ -15,7 +15,7 @@ jobs:
15
15
  runs-on: ubuntu-latest
16
16
  steps:
17
17
  - name: Checkout
18
- uses: actions/checkout@v3
18
+ uses: actions/checkout@v4
19
19
 
20
20
  - name: Setup
21
21
  uses: ./.github/actions/setup
@@ -30,7 +30,7 @@ jobs:
30
30
  runs-on: ubuntu-latest
31
31
  steps:
32
32
  - name: Checkout
33
- uses: actions/checkout@v3
33
+ uses: actions/checkout@v4
34
34
 
35
35
  - name: Setup
36
36
  uses: ./.github/actions/setup
@@ -42,7 +42,7 @@ jobs:
42
42
  runs-on: ubuntu-latest
43
43
  steps:
44
44
  - name: Checkout
45
- uses: actions/checkout@v3
45
+ uses: actions/checkout@v4
46
46
 
47
47
  - name: Setup
48
48
  uses: ./.github/actions/setup
@@ -57,13 +57,13 @@ jobs:
57
57
  TURBO_CACHE_DIR: .turbo/android
58
58
  steps:
59
59
  - name: Checkout
60
- uses: actions/checkout@v3
60
+ uses: actions/checkout@v4
61
61
 
62
62
  - name: Setup
63
63
  uses: ./.github/actions/setup
64
64
 
65
65
  - name: Cache turborepo for Android
66
- uses: actions/cache@v3
66
+ uses: actions/cache@v4
67
67
  with:
68
68
  path: ${{ env.TURBO_CACHE_DIR }}
69
69
  key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }}
@@ -80,7 +80,7 @@ jobs:
80
80
 
81
81
  - name: Install JDK
82
82
  if: env.turbo_cache_hit != 1
83
- uses: actions/setup-java@v3
83
+ uses: actions/setup-java@v4
84
84
  with:
85
85
  distribution: 'zulu'
86
86
  java-version: '17'
@@ -92,7 +92,7 @@ jobs:
92
92
 
93
93
  - name: Cache Gradle
94
94
  if: env.turbo_cache_hit != 1
95
- uses: actions/cache@v3
95
+ uses: actions/cache@v4
96
96
  with:
97
97
  path: |
98
98
  ~/.gradle/wrapper
@@ -108,18 +108,18 @@ jobs:
108
108
  yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
109
109
 
110
110
  build-ios:
111
- runs-on: macos-14
111
+ runs-on: macos-latest
112
112
  env:
113
113
  TURBO_CACHE_DIR: .turbo/ios
114
114
  steps:
115
115
  - name: Checkout
116
- uses: actions/checkout@v3
116
+ uses: actions/checkout@v4
117
117
 
118
118
  - name: Setup
119
119
  uses: ./.github/actions/setup
120
120
 
121
121
  - name: Cache turborepo for iOS
122
- uses: actions/cache@v3
122
+ uses: actions/cache@v4
123
123
  with:
124
124
  path: ${{ env.TURBO_CACHE_DIR }}
125
125
  key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }}
@@ -134,10 +134,10 @@ jobs:
134
134
  echo "turbo_cache_hit=1" >> $GITHUB_ENV
135
135
  fi
136
136
 
137
- - name: Cache cocoapods
137
+ - name: Restore cocoapods
138
138
  if: env.turbo_cache_hit != 1
139
139
  id: cocoapods-cache
140
- uses: actions/cache@v3
140
+ uses: actions/cache/restore@v4
141
141
  with:
142
142
  path: |
143
143
  **/ios/Pods
@@ -153,6 +153,14 @@ jobs:
153
153
  env:
154
154
  NO_FLIPPER: 1
155
155
 
156
+ - name: Cache cocoapods
157
+ if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
158
+ uses: actions/cache/save@v4
159
+ with:
160
+ path: |
161
+ **/ios/Pods
162
+ key: ${{ steps.cocoapods-cache.outputs.cache-key }}
163
+
156
164
  - name: Build example for iOS
157
165
  run: |
158
166
  yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"
@@ -161,7 +169,7 @@ jobs:
161
169
  runs-on: ubuntu-latest
162
170
  steps:
163
171
  - name: Checkout
164
- uses: actions/checkout@v3
172
+ uses: actions/checkout@v4
165
173
 
166
174
  - name: Setup
167
175
  uses: ./.github/actions/setup
@@ -1 +1 @@
1
- v18
1
+ v20
@@ -1,6 +1,7 @@
1
- import { useState, useEffect } from 'react';
2
- import { Text, View, StyleSheet } from 'react-native';
3
1
  import { multiply } from '<%- project.slug -%>';
2
+ import { Text, View, StyleSheet } from 'react-native';
3
+ <% if (project.native) { -%>
4
+ import { useState, useEffect } from 'react';
4
5
 
5
6
  export default function App() {
6
7
  const [result, setResult] = useState<number | undefined>();
@@ -9,6 +10,12 @@ export default function App() {
9
10
  multiply(3, 7).then(setResult);
10
11
  }, []);
11
12
 
13
+ <% } else { -%>
14
+
15
+ const result = multiply(3, 7);
16
+
17
+ export default function App() {
18
+ <% } -%>
12
19
  return (
13
20
  <View style={styles.container}>
14
21
  <Text>Result: {result}</Text>
@@ -24,7 +24,6 @@ class <%- project.name -%>Package : BaseReactPackage() {
24
24
  <%- project.name -%>Module.NAME,
25
25
  false, // canOverrideExistingModule
26
26
  false, // needsEagerInit
27
- true, // hasConstants
28
27
  false, // isCxxModule
29
28
  true // isTurboModule
30
29
  )
@@ -1,6 +1,7 @@
1
1
  buildscript {
2
- // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
- def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["<%- project.name -%>_kotlinVersion"]
2
+ ext.getExtOrDefault = {name ->
3
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['<%- project.name -%>_' + name]
4
+ }
4
5
 
5
6
  repositories {
6
7
  google()
@@ -8,16 +9,18 @@ buildscript {
8
9
  }
9
10
 
10
11
  dependencies {
11
- classpath "com.android.tools.build:gradle:7.2.1"
12
+ classpath "com.android.tools.build:gradle:8.7.2"
12
13
  // noinspection DifferentKotlinGradleVersion
13
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
14
15
  }
15
16
  }
16
17
 
18
+ <% if (project.cpp) { -%>
17
19
  def reactNativeArchitectures() {
18
20
  def value = rootProject.getProperties().get("reactNativeArchitectures")
19
21
  return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
20
22
  }
23
+ <% } -%>
21
24
 
22
25
  def isNewArchitectureEnabled() {
23
26
  return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
@@ -30,10 +33,6 @@ if (isNewArchitectureEnabled()) {
30
33
  apply plugin: "com.facebook.react"
31
34
  }
32
35
 
33
- def getExtOrDefault(name) {
34
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["<%- project.name -%>_" + name]
35
- }
36
-
37
36
  def getExtOrIntegerDefault(name) {
38
37
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["<%- project.name -%>_" + name]).toInteger()
39
38
  }
@@ -131,10 +130,7 @@ repositories {
131
130
  def kotlin_version = getExtOrDefault("kotlinVersion")
132
131
 
133
132
  dependencies {
134
- // For < 0.71, this will be from the local maven repo
135
- // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
136
- //noinspection GradleDynamicVersion
137
- implementation "com.facebook.react:react-native:+"
133
+ implementation "com.facebook.react:react-android"
138
134
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
139
135
  }
140
136
 
@@ -1,5 +1,5 @@
1
- <%- project.name -%>_kotlinVersion=1.7.0
2
- <%- project.name -%>_minSdkVersion=21
3
- <%- project.name -%>_targetSdkVersion=31
4
- <%- project.name -%>_compileSdkVersion=31
5
- <%- project.name -%>_ndkversion=21.4.7075529
1
+ <%- project.name -%>_kotlinVersion=2.0.21
2
+ <%- project.name -%>_minSdkVersion=24
3
+ <%- project.name -%>_targetSdkVersion=34
4
+ <%- project.name -%>_compileSdkVersion=35
5
+ <%- project.name -%>_ndkversion=27.1.12297006
@@ -20,6 +20,7 @@ Pod::Spec.new do |s|
20
20
  s.source_files = "ios/**/*.{h,m,mm,swift}"
21
21
  <% } else if (project.arch !== "legacy") { -%>
22
22
  s.source_files = "ios/**/*.{h,m,mm,cpp}"
23
+ s.private_header_files = "ios/generated/**/*.h"
23
24
  <% } else { -%>
24
25
  s.source_files = "ios/**/*.{h,m,mm}"
25
26
  <% } -%>