create-sparkling-app 2.0.0-rc.5 → 2.0.0-rc.8

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.
@@ -54,6 +54,7 @@ async function installDependencies(distFolder, packageManager) {
54
54
  }
55
55
  async function initializeGitRepo(distFolder) {
56
56
  const stdioMode = (0, verbose_1.isVerboseEnabled)() ? 'inherit' : 'pipe';
57
+ const s = (0, spinner_1.createSpinner)();
57
58
  try {
58
59
  try {
59
60
  (0, node_child_process_1.execSync)('git --version', { stdio: stdioMode });
@@ -62,6 +63,7 @@ async function initializeGitRepo(distFolder) {
62
63
  console.warn(ui_1.ui.warn('Warning: Git is not installed or not in PATH. Skipping git initialization.'));
63
64
  return;
64
65
  }
66
+ s.start('Initializing git repository...');
65
67
  if ((0, verbose_1.isVerboseEnabled)()) {
66
68
  (0, verbose_1.verboseLog)(`Initializing git repository in ${distFolder}`);
67
69
  }
@@ -69,15 +71,16 @@ async function initializeGitRepo(distFolder) {
69
71
  try {
70
72
  (0, node_child_process_1.execSync)('git add .', { cwd: distFolder, stdio: stdioMode });
71
73
  (0, node_child_process_1.execSync)('git commit -m "init: scaffolded by sparkling"', { cwd: distFolder, stdio: stdioMode });
72
- console.log(ui_1.ui.success('Initialized empty Git repository'));
74
+ s.stop('Initialized git repository');
73
75
  console.log(ui_1.ui.success('✔ Created initial commit: "init: scaffolded by sparkling"'));
74
76
  }
75
77
  catch (error) {
76
- console.log(ui_1.ui.success('Initialized empty Git repository'));
78
+ s.stop('Initialized git repository');
77
79
  console.warn(ui_1.ui.warn('Warning: Git repository initialized but initial commit failed. Configure git user.name and user.email, then run "git add . && git commit -m \"init: scaffolded by sparkling\"" manually.'));
78
80
  }
79
81
  }
80
82
  catch (error) {
83
+ s.stop('Failed to initialize git repository');
81
84
  console.warn(ui_1.ui.warn('Warning: Failed to initialize git repository. Run "git init" manually.'));
82
85
  }
83
86
  }
@@ -125,11 +125,11 @@ async function createSparklingApp(options) {
125
125
  templateVersion = undefined;
126
126
  }
127
127
  if (builtinTemplate?.canonicalName === constants_1.DEFAULT_TEMPLATE_NAME) {
128
- const cliTemplateVersion = version ?? "0.0.0";
129
- if (templateVersion && templateVersion !== cliTemplateVersion) {
130
- console.log(ui_1.ui.warn(`Template version ${templateVersion} does not match CLI version ${cliTemplateVersion}; using CLI version.`));
128
+ // Always use the latest template from npm unless the user explicitly
129
+ // provides a specific version via --template-version.
130
+ if (!userProvidedTemplateVersion) {
131
+ templateVersion = undefined; // resolves to "latest" in resolveDefaultTemplate
131
132
  }
132
- templateVersion = cliTemplateVersion;
133
133
  }
134
134
  const androidDsl = await (0, user_prompts_1.askAndroidDsl)(flags);
135
135
  const devTools = await (0, user_prompts_1.askDevTools)(flags);
@@ -232,6 +232,7 @@ async function createSparklingApp(options) {
232
232
  didInstall = await (0, post_create_1.installDependencies)(distFolder, packageManager);
233
233
  }
234
234
  if (shouldInitGit) {
235
+ console.log(ui_1.ui.info('Setting up git repository, this may take a moment...'));
235
236
  await (0, post_create_1.initializeGitRepo)(distFolder);
236
237
  }
237
238
  (0, post_create_1.showCompletionNotes)(targetDir, packageManager, didInstall);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-sparkling-app",
3
- "version": "2.0.0-rc.5",
4
- "homepage": "",
3
+ "version": "2.0.0-rc.8",
4
+ "homepage": "https://tiktok.github.io/sparkling/",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/tiktok/sparkling",
package/dist/build.js DELETED
@@ -1,118 +0,0 @@
1
- "use strict";
2
- // Copyright (c) 2025 TikTok Pte. Ltd.
3
- // Licensed under the Apache License Version 2.0 that can be found in the
4
- // LICENSE file in the root directory of this source tree.
5
- var __importDefault = (this && this.__importDefault) || function (mod) {
6
- return (mod && mod.__esModule) ? mod : { "default": mod };
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- const child_process_1 = require("child_process");
10
- const util_1 = require("util");
11
- const execAsync = (0, util_1.promisify)(child_process_1.exec);
12
- const path_1 = __importDefault(require("path"));
13
- const util_2 = require("./util");
14
- const runCommand = (command, args, cwd) => {
15
- return new Promise((resolve, reject) => {
16
- console.log(`Executing: ${command} ${args.join(' ')} in ${cwd}`);
17
- const child = (0, child_process_1.spawn)(command, args, { cwd, stdio: 'inherit' });
18
- child.on('error', (error) => {
19
- console.error(`Error with command ${command}: ${error}`);
20
- reject(error);
21
- });
22
- child.on('exit', (code) => {
23
- if (code !== 0) {
24
- const errorMsg = `Command ${command} exited with code ${code}`;
25
- console.error(errorMsg);
26
- reject(new Error(errorMsg));
27
- }
28
- else {
29
- resolve();
30
- }
31
- });
32
- });
33
- };
34
- const buildFrontend = (projectDir) => {
35
- const command = 'pnpm';
36
- const args = ['run', 'dev'];
37
- return runCommand(command, args, projectDir);
38
- };
39
- const buildAndroid = (projectDir) => {
40
- const androidDir = path_1.default.join(projectDir, 'android');
41
- const command = './gradlew';
42
- const args = ['build'];
43
- return runCommand(command, args, androidDir);
44
- };
45
- const buildIos = async (projectDir) => {
46
- const iosDir = path_1.default.join(projectDir, 'ios');
47
- try {
48
- const scheme = 'SparklingGo';
49
- const workspace = 'SparklingGo.xcworkspace';
50
- const configuration = 'Debug';
51
- const build_dir = path_1.default.join(iosDir, 'build');
52
- console.log('Finding available simulator...');
53
- const { stdout: devicesOutput } = await execAsync('xcrun simctl list devices available');
54
- const simulatorLine = devicesOutput.split('\n').find(line => line.includes('iPhone')) ?? '';
55
- if (!simulatorLine) {
56
- throw new Error('No available iPhone simulator found.');
57
- }
58
- const simulatorName = simulatorLine.split('(')[0].trim();
59
- console.log(`Using simulator: ${simulatorName}`);
60
- const destination = `platform=iOS Simulator,name=${simulatorName},OS=latest`;
61
- await runCommand('xcodebuild', ['clean', '-workspace', workspace, '-scheme', scheme, '-configuration', configuration], iosDir);
62
- await runCommand('xcodebuild', ['build', '-workspace', workspace, '-scheme', scheme, '-configuration', configuration, '-destination', destination, '-derivedDataPath', build_dir], iosDir);
63
- const { stdout: appPath } = await execAsync(`find "${build_dir}" -name "*.app" | head -n 1`);
64
- if (!appPath) {
65
- throw new Error('.app file not found.');
66
- }
67
- console.log(`App found at: ${appPath.trim()}`);
68
- try {
69
- await execAsync(`xcrun simctl boot "${simulatorName}"`);
70
- }
71
- catch (e) {
72
- console.log('Simulator already booted.');
73
- }
74
- await runCommand('xcrun', ['simctl', 'install', 'booted', appPath.trim()], projectDir);
75
- const { stdout: bundleId } = await execAsync(`/usr/libexec/PlistBuddy -c "Print:CFBundleIdentifier" "${appPath.trim()}/Info.plist"`);
76
- await runCommand('xcrun', ['simctl', 'launch', 'booted', bundleId.trim()], projectDir);
77
- console.log('iOS build completed successfully.');
78
- }
79
- catch (error) {
80
- console.error(`iOS build failed: ${error.message}`);
81
- throw error;
82
- }
83
- };
84
- const buildAll = async (projectDir) => {
85
- try {
86
- await Promise.all([
87
- buildFrontend(projectDir),
88
- buildAndroid(projectDir),
89
- buildIos(projectDir),
90
- ]);
91
- }
92
- catch (error) {
93
- console.error('A build step failed. Aborting.');
94
- process.exit(1);
95
- }
96
- };
97
- exports.default = async (buildType) => {
98
- console.log('Building Sparkling Lynx project...');
99
- const projectRoot = (0, util_2.findSparklingProjectRoot)();
100
- if (!projectRoot) {
101
- throw new Error('Failed to find Sparkling project root');
102
- }
103
- if (!buildType || buildType === 'all') {
104
- await buildAll(projectRoot);
105
- }
106
- else if (buildType === 'frontend') {
107
- await buildFrontend(projectRoot);
108
- }
109
- else if (buildType === 'android') {
110
- await buildAndroid(projectRoot);
111
- }
112
- else if (buildType === 'ios') {
113
- await buildIos(projectRoot);
114
- }
115
- else {
116
- throw new Error(`Invalid build type: ${buildType}`);
117
- }
118
- };
package/dist/util.js DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
- // Copyright (c) 2025 TikTok Pte. Ltd.
3
- // Licensed under the Apache License Version 2.0 that can be found in the
4
- // LICENSE file in the root directory of this source tree.
5
- var __importDefault = (this && this.__importDefault) || function (mod) {
6
- return (mod && mod.__esModule) ? mod : { "default": mod };
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.findSparklingProjectRoot = findSparklingProjectRoot;
10
- const fs_1 = __importDefault(require("fs"));
11
- const path_1 = __importDefault(require("path"));
12
- function findSparklingProjectRoot(startDir = process.cwd()) {
13
- let currentDir = startDir;
14
- while (!fs_1.default.existsSync(path_1.default.join(currentDir, 'package.json'))) {
15
- const parentDir = path_1.default.dirname(currentDir);
16
- if (parentDir === currentDir) {
17
- return null;
18
- }
19
- currentDir = parentDir;
20
- }
21
- return currentDir;
22
- }