codeplay-common

中文文档
4.11.10发布于 2026/11/03MIT

Common build scripts and files

原始使用文档
文档目录7 节
  1. Capacitor Android permission metadata (4.11.4)
  2. App helper folder
  3. Shared unversioned build files (4.10.0)
  4. AdMob folder packages
  5. Platform builds and shared validation
  6. Screenshot data
  7. Agent instructions

codeplay-common

Everything automatted in Capacitor apps, easy to maintain many apps in capacitor. It will reduce your 40% of work, with common file code.

Easy add splashscreen and set animation Admob id automatically from capacitor.config.json file Make three build file for different store as per our requirement Based on store install various IAP plugins Make it to ionic project

Capacitor Android permission metadata (4.11.4)

The package preserves the runtime CapacitorPlugin and Permission annotation members required by optimized Android builds. This applies to every Android consumer, even if the app does not currently use permission-dependent plugins. It does not declare or grant permissions, show prompts, or enable minification.

Installation applies the rules to an existing Android project and installs one apply from line in android/app/build.gradle. The included Gradle script reruns the repair during every Gradle configuration, including direct Android Studio/Gradle and Capacitor run --no-sync builds. All repair logic stays in the shared fix folder. Android sync, build preparation and release preparation restore missing rules after platform regeneration. The generated Gradle hook is restored after platform regeneration. Existing custom ProGuard rules are preserved and repeated runs do not add duplicates. Apps without an Android platform are skipped until that platform exists.

All fix implementations ship under buildCodeplay/fix-optimize-builld/, including the restore command and its Gradle integration; no app-specific Scripts file is required. Run npm run android:r8-rules to restore the rules manually. Existing custom npm commands are preserved; the known older restore-android-r8-rules.cjs command is migrated automatically.

After installing this package update, rebuild and test each app's optimized release. Updating build tooling cannot change APKs or app-store releases already distributed to users.

App helper folder

Application helper scripts are kept in scripts-common/. Installation migrates the old scripts/ folder and package command paths automatically, preserving every existing file. A conflicting destination file stops migration before any files are moved. The plugin’s internal npm lifecycle folder remains scripts/.

Shared unversioned build files (4.10.0)

The plugin keeps the master build templates in files/buildCodeplay and copies them into each app's buildCodeplay folder during installation/update. Test changes in the application folder, then update these master templates for distribution to other apps.

App package scripts run local files: node buildCodeplay/codeplayBeforeBuild.js, node buildCodeplay/packageidBaseModification.js, node buildCodeplay/add-splash-screen.js and node buildCodeplay/setSplashAnimation.js. Filenames have no version suffixes. The versions.json plugin manifest remains alongside these scripts and is copied too.

Installation migrates both legacy versioned filenames and the temporary node_modules runner commands to these local paths. It removes only superseded versioned build scripts, preserves app-owned release configuration and splash XML overrides, and keeps screenshot data and custom helpers. The root finalrelease script is also copied as a local implementation.

After this update is installed, npm run build checks the app's buildCodeplay/ folder for version-suffixed files before preparing the build. If any exist, it runs npm uninstall codeplay-common followed by npm install codeplay-common, then runs the refreshed before-build script before continuing. A failed command or remaining versioned files stops the build. Unrecognized legacy files must be migrated manually; they are not deleted automatically.

Before-build includes the automatic IAP startup and Home Pro-button migrations. IAP and AdMob ZIPs are downloaded directly from https://htmlcodeplay.com/code-play-plugin/ using the existing update flow. No plugin ZIPs are bundled in this npm package. App-specific configuration and designs remain in the app.

AdMob folder packages

The next before-build automatically migrates AdMob to at least:

src/js/Ads/admob-nextgen-4.1/admob-emi-nextgen.js

src/js/Ads/admob-nextgen-4.1/app-open-state.js

Existing @admob imports continue to work. Direct imports of the controller or lightweight state module are rewritten to the selected folder, including relative paths, @/ paths and static dynamic imports. App-owned src/js/Ads/admob-ad-configuration-nextgen.json remains outside the package; installation does not replace its values. The controller's analytics import is aligned with the newest installed IAP folder containing firebase-analytics.js.

The pre-build script downloads IAP before migrating AdMob so the corresponding imports exist. Postinstall does not independently update AdMob ahead of IAP. ZIPs may contain the files directly or one matching versioned folder. A complete controller and state module are required before imports switch. An unavailable or invalid remote ZIP leaves the installed package in use, with a warning. Unresolved import targets stop migration before old packages are removed.

For future AdMob releases, upload admob-nextgen-X.Y.zip to https://htmlcodeplay.com/code-play-plugin/ and set "admob-nextgen": "X.Y" in that server's versions.json. Version the folder, and keep module filenames stable. The previous admob-emi-nextgen manifest key is accepted for versions 4.0 and later during the transition. Apps automatically select a newer ZIP during their next normal pre-build; no per-app import changes are needed. For older manifests without a folder release entry, migration checks the required admob-nextgen-4.1.zip directly from the same server. If offline, an existing compatible installation is preserved; a missing required package stops the build.

Platform builds and shared validation

Installing or updating codeplay-common updates the consuming project's package.json to use the copied unversioned pre-build script and adds these commands:

  • npm run build: Android by default, including on macOS.
  • npm run build:ios: sets CODEPLAY_BUILD_PLATFORM=ios and runs the same build pipeline.
  • npm run build-capacitor-android: runs the shared checks and copies the web build to Android.

The pre-build script migrates direct saveToGalleryAndSaveAnyFile imports to @saveGallery and sets the Vite alias to the matching Android or iOS helper. Before changing source imports or the alias, it lists the build target, affected files, and exact replacements. Press Enter or type y to continue; any other answer cancels. Correct imports and alias targets continue without prompting. Missing helpers, mixed versions and query/hash imports stop with an actionable error.

Source validation reuses a directory inventory and combines the gallery and editor checks in one content pass. The inventory refreshes when generated or downloaded files change the source tree.

Builds also keep agent-temp/ ignored and remove existing buildCodeplay/ ignore entries. If onesignal-cordova-plugin is declared or installed, the pre-build script warns and runs npm uninstall onesignal-cordova-plugin. It stops if removal fails or active package imports remain. Legacy OneSignal patching and helper downloads are disabled.

Screenshot data

Shared screenshot helpers are installed into scripts-common/screenshot/ and updated with the package. App-specific data is not bundled with the package. During an upgrade, cleanup removes only the two legacy helpers frame-samples.js and background-decorations.js from scripts-screenshot/screenshot/, preserving the folder, JSON data, and other app files.

take-screen-image.js creates scripts-screenshot/screenshot/ and empty screenshot-copy.json and screenshot-info.json files when needed. Existing files are preserved during initialization, package installation, and cleanup. Capture updates screenshot information; the AI text-generation workflow fills screenshot copy. --delete removes matching records, and screenshot runs reconcile records against the captured images (except dry runs and --refresh-info).

Agent instructions

Agent instructions are updated during npm run build, not during npm installation. The build script reads the agents version from https://htmlcodeplay.com/code-play-plugin/versions.json and downloads the matching agents-<version>.zip archive when the project has no agent instructions or the server version is newer.

The ZIP root must contain AGENTS.md and AGENTS/. These are copied directly to the project root. The installed version is stored in AGENTS/.codeplay-version. Existing files with matching names are replaced; project-only files with other names inside AGENTS/ are preserved.

For example, publish agents-1.1.zip and add this entry to the server's versions.json:

"agents": "1.1"

Donate to get full code including many common functions https://ko-fi.com/codeplay

Version 4.6.1 Added automatic IAP startup integration for Framework7 home pages. Updated minimum shared versions to IAP 4.2 and AdMob nextgen 2.5.

4.2.8 baseline profile code modifications

Version 4.2.3 Added build warning confirmation when android.ORIENTATION is not "auto" or android.RESIZEABLE_ACTIVITY is not true.

Version 4.2.2 Added "bannerDisabledPages" property and its default value The admob configuration default value priority is updated

Version 4.2.1 Updated AdMob nextgen file validation to match admob-emi-nextgen file names.

Version 4.2.0 Firebase related automatic changes updated

Version 4.1.9 Added AdMob nextgen 1.7 validation/default support for "overlappingHeight", "bannerTypeAndroidLandscape", and "bannerTypeiOSLandscape".

Version 4.1.8 "consentDebug: false" is added

Version 4.1.7 admob configuration automatically added.

Version 4.1.6 "setup-baseline-profile.js" modification, duplicate validation error fixed

Version 4.1.5 While isTesting is true it is not validated from our new configuration admob file, now it is solved

Version 4.1.4 hardcoded version is removed for the admob-emi-nextgen

Version 4.1.3 "consentDebug": false automatically adds if not

Version 4.1.2 Speedup

Version 4.1.1 Auto admob integration updated

version 4.0.9 packageJson.scripts["ionic:serve"] = "cross-env NODE_ENV=development vite"; this line updated in "sync-files.js"

version 4.0.8 safearea plugin is checked and removed automatically Automatically added following in capacitor.config.json file "SystemBars": { "insetsHandling": "css" } patchFile() method is removed

Version 4.0.6 IAP related some automatic variable creation and validation Fetch from vite.config.json file 'import.meta.env.VITE_APP_UNIQUE_ID': JSON.stringify(APP_UNIQUE_ID), 'import.meta.env.VITE_ANDROID_ANALYTICS_ENABLED': JSON.stringify(ANDROID_ANALYTICS_ENABLED), 'import.meta.env.VITE_IOS_ANALYTICS_ENABLED': JSON.stringify(IOS_ANALYTICS_ENABLED), 'import.meta.env.VITE_IAP_DESIGN': JSON.stringify(IAP_DESIGN),

Version 4.0.5 In "files\buildCodeplay\packageidBaseModification-1.4.js" SCHEDULE_EXACT_ALARM permission added for the app unique id 2 (resume generator app)

Version 4.0.4 patchFile(); method is disabled, Due to "@capacitor/android:8.4.2" this update. I think it is realted to safearea issue fixed in this latest version, file in "SystemBars.java"

Version 4.0.3 Old admob check performs through plugin location, but not it is validated from capacitor.config.json

Version: 4.0.2 After check & install/download the latest version, the re-check is cancelled now

Version: 4.0.1 Base profile script added

"version": "", Version : 4.0.0 (Previous version 3.2.19) 1) In here we are completly remove the admob-emi and use "capacitor-admob-nextgen" 2) Removed "modify-plugin-xml.js" 3)

The fix preserves the metadata behind the release permission-check failure verified in testing. It does not guarantee every native dialog or plugin: required manifest declarations, Android permission policy, device settings and plugin-specific keep rules still apply.

版本与发布记录

codeplay-common 共发布 374 个版本,首次发布于 2025/02/19;过去 12 个月发布了 222 个版本。

版本发布日期距今
4.11.10latest2026/11/03今天
4.11.92026/11/02今天
4.11.82026/11/021 天前
4.11.72026/10/304 天前
4.11.62026/10/304 天前
4.11.52026/10/286 天前

关于 codeplay-common 的常见问题

codeplay-common 是什么?

通用构建脚本和文件

如何安装 codeplay-common?

在项目目录运行 npm install codeplay-common,或使用 pnpm add / yarn add / bun add。

codeplay-common 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/codeplay-common 是否存在。

codeplay-common 可以商用吗?

codeplay-common 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

codeplay-common 还在维护吗?

最新版本 4.11.10 发布于 2026/11/03(今天);至今共发布 374 个版本,其中过去 12 个月发布了 222 个;首次发布于 2025/02/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。